title: Dynamic generated form in Yii2
body: <p>I'm learning programming in yii2 framework, and I can't find out how to achieve specific task: I want to generate monthly statistic based on collected data. For this task, I need to generate form, that will wary on number of projects and users. For example:</p>
  
  <pre><code>Project 1: 500$
   user1 field (in fields I want to put percentage of above value)
   user2 field
   user3 field
  
  project 2: 1000$
   user2 field
   user3 field
  </code></pre>
  
  <p>And so on. It's easy to do in structural way, and save results in serialized form, but this way I'm unable to validate (for example if sum of values in fields for given project excess 100% and if there was error, after sending form, data would be erased). 
  Is it possible to achieve such task with Yii2?</p>
  
  <p>edit:
  currently I'm generating form this way:</p>
  
  <p>controller:</p>
  
  <pre><code>        $date = "2015-05";
      $model = new Raport();
      $invoices = Faktura::find()-&gt;where(['LIKE','paid_date', $date])-&gt;all();
  
  $projects = array();
  
          foreach($invoices as $invoice){
          $id = $invoice-&gt;project_id;
          $projects[$id]['faktury'][] = $invoice;
          $projects[$id]['model']= Project::find()-&gt;where(['id'=&gt;$invoice-&gt;project_id])-&gt;one();
          $projects[$id]['value']+= $invoice-&gt;value_netto;
          $projects[$id]['users']= '' ;
          $checks = Check::find()-&gt;where(['project_id'=&gt;$id])-&gt;all();
          if (empty($checks)){
              $projects[$id]['users']=$projects[$id]['model']-&gt;users;
          }else {
              foreach ($checks as $check) {
                  $projects[$id]['users'][$check-&gt;user-&gt;id] = $check-&gt;user;
              }
          }
      }
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>   foreach ($projects as $key =&gt; $project) {
      echo"&lt;h2&gt;".$project['model']-&gt;name."&lt;/h2&gt;";
      echo 'project value: '.$project['value'];
      echo"&lt;p&gt;percentage value:&lt;/p&gt;";
  
    //  echo"&lt;pre&gt;";
      foreach ($project['users'] as $user) {
  
          echo"&lt;p&gt;".$user-&gt;email."&lt;/p&gt;";
          echo "&lt;input name='Raport[".$key."][".$user-&gt;id."]'&gt;";
      }
  }
  </code></pre>