title: Using CakePHP form validation with angular JS
body: <p>I am building a simple invoice module using angular js and cake php.</p>
  
  <p>The items fields are repeated using ng - repeat in my view as seen below </p>
  
  <pre><code>    &lt;div ng:controller="ItemsCtrl" ng:app&gt;
  &lt;div class="row-fluid items" &gt;
      &lt;hr&gt;
      &lt;ul class="invoice_items" ng:init="invoice={items:[{serial:'',details:'',qty:0,unit:'',rate:0,discount:0,amount:0}],pf:0}"&gt;
      &lt;li ng:repeat="item in invoice.items"&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;div id="items_row"&gt;
          &lt;div class="field span1"&gt;
                              &lt;?php   
                          echo $this-&gt;TwitterBootstrap-&gt;input("Number", array(
                              "input" =&gt; $this-&gt;Form-&gt;text("Item.{{\$index}}.serial" , array('class' =&gt; 'serial span1' ,'placeholder' =&gt; 'S.No' , 'ng-model' =&gt; 'item.serial' , 'value' =&gt; '{{ $index + 1 }}' , 'readonly' =&gt; 'readonly' ))
                          )); ?&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Closing the appropriate tags in the end</p>
  
  <p>I have the following code in my model for validation - </p>
  
  <pre><code>public $validate = array(
      'id' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
      ),
      'serial' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
      ),
      'details' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
      ),
      'quantity' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
          'naturalnumber' =&gt; array(
              'rule' =&gt; array('naturalnumber'),
              'message' =&gt; 'Please enter a valid quantity'
  
          ),
      ),
      'rate' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
          'numeric' =&gt; array(
              'rule' =&gt; array('numeric'),
  
          ),
      ),
      'discount' =&gt; array(
          'numeric' =&gt; array(
              'rule' =&gt; array('numeric'),
  
          ),
      ),
      'amount' =&gt; array(
          'notempty' =&gt; array(
              'rule' =&gt; array('notempty'),
  
          ),
          'numeric' =&gt; array(
              'rule' =&gt; array('numeric'),
  
          ),
      ),
  );
  </code></pre>
  
  <p><strong>The issue is that the fields which are outside of the ng-repeat directive get validated as required , but since the fields inside ng-repeat get initialized on each page load, cakephp validation isnt applied to them .</strong></p>
  
  <p>Do you guys see any work around to this ? May be my entire architecture approach is wrong?</p>