title: Yii2 : validate if at least one checkbox is selected
body: <p>I have multiple Music releases for a user for which he wants to create a promo, on the promo create form we have all the releases listed and I am using a form model for creating the promo where I define all rules for my several inputs in the promo form model.</p>
  
  <p>I want to check if at-least one release is selected by the user when saving the form but it is not working as the checkboxes are created dynamically.</p>
  
  <p>my form code for that field</p>
  
  <pre><code>foreach ($releaseInfo as $releases) {
      if (!is_null($releases-&gt;releaseSongs)) {
          echo "&lt;fieldset&gt;&lt;legend&gt;" . \yii\helpers\Html::activeCheckbox($model, 'selected_releases[]', ['id' =&gt; 'release_' . $releases-&gt;id, 'onclick' =&gt; '$("#songs_' . $releases-&gt;id . '").toggle()', 'label' =&gt; false]) . "&amp;nbsp;" . $releases-&gt;name . "&lt;/legend&gt;";
          foreach ($releases-&gt;releaseSongs as $k =&gt; $v) {
              echo "&lt;div id='songs_" . $releases-&gt;id . "' style='display:none'&gt;";
              echo "&lt;div&gt;";
              echo $v-&gt;song-&gt;name;
              echo "&lt;/div&gt;";
              echo "&lt;/div&gt;";
          }
      }
  }
  
  echo "&lt;/fieldset&gt;";
  </code></pre>
  
  <p>my rule in model</p>
  
  <pre><code>['selected_releases', 'required', 'on' =&gt; ['catalog', 'catalog_update'], 'requiredValue' =&gt; 1,
      'when' =&gt; function ($model) {return ($model-&gt;scenario == self::SCENARIO_CATALOG_BASED || $model-&gt;scenario == self::SCENARIO_CATALOG_BASED_UPDATE);},
      'whenClient' =&gt; 'function(attribute,value){return ("' . $this-&gt;scenario . '"=="' . self::SCENARIO_CATALOG_BASED . '" || "' . $this-&gt;scenario . '"=="' . self::SCENARIO_CATALOG_BASED_UPDATE . '")}',
      'message' =&gt; 'You must select atleast one release',
  ]
  </code></pre>
  
  <p>when i submit my form the posted input variable looks like this </p>
  
  <pre><code> [selected_releases] =&gt; Array(
              [0] =&gt; 0
              [1] =&gt; 0
   )
  </code></pre>
  
  <p>the <code>requiredValue</code> in the rule does not work because the <code>selected_releases</code> is an array of values it always says that </p>
  
  <p><code>You must select atleast one release</code> 
  how shoule i use the <code>requiredValue</code> parameter option for rules in a way that it checks for atleast one slection of the checkbox </p>
  
  <p>OR </p>
  
  <p>do i have to make a custom validation method an call it when validating</p>