title: codeigniter form validation for dynamic form input names
body: <p>I have a codeigniter app. My view uses the database row ID to append to the input name to get a unique ID. this allows me to use all inputs in my form action, which is update.</p>
  
  <p><strong>my View syntax:</strong></p>
  
  <pre><code>&lt;?php if(isset($records)) {?&gt;
  &lt;table id="hor-minimalist-a"&gt;
      &lt;tr&gt;
          &lt;th&gt;&amp;nbsp;&lt;/th&gt;&lt;th&gt;&amp;nbsp;&lt;/th&gt;&lt;th&gt;Customer Name&lt;/th&gt;&lt;th&gt;postalcode&lt;/th&gt;
      &lt;tr&gt;
  
  &lt;?php if(isset($records)) : foreach ($records as $row) : ?&gt;
      &lt;tr&gt;
          &lt;td&gt;
  &lt;?php echo anchor('masterdata/confirm_delete_customer/'.$row-&gt;id, img(array('src'=&gt;'images/delete_icon.png','border'=&gt;'0','alt'=&gt;'Delete'))); ?&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type=checkbox name="editcustomer[]" id="editcustomer[]" value="&lt;?php echo $row-&gt;id ?&gt;"&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input class="inputwide" type="text" name="customer_name_&lt;?php echo $row-&gt;id ?&gt;" id="customer_name_&lt;?php echo $row-&gt;id ?&gt;" value="&lt;?php echo $row-&gt;customer_name ; ?&gt;" &gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input class="inputnarrow" type="text" name="postalcode_&lt;?php echo $row-&gt;id ?&gt;" id="postalcode_&lt;?php echo $row-&gt;id ?&gt;" value="&lt;?php echo $row-&gt;postalcode ; ?&gt;" &gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php endforeach ; ?&gt;
      &lt;/table&gt;
  &lt;input type="submit" value="Update Checked Customers"&gt;
  &lt;?php endif; ?&gt;
  
  &lt;?php echo form_close(); ?&gt;
  &lt;?php } else {?&gt;
  &lt;h4 id="warning"&gt; No Customers currently in database&lt;/h4&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>as you can see the input <code>name's</code> and <code>id's</code> are then unique.</p>
  
  <p><strong>My controller syntax is below:</strong></p>
  
  <pre><code>function manage_customers()
      {
  
          $data['title']="Manage Customers";
  
              //query model to get data results for form
              $data=array();
  
              if($query=$this-&gt;model_master_data-&gt;get_customer_records()){
                  $data['records']=$query;
              }
  
              $this-&gt;load-&gt;view("master_data/view_master_data_header",$data);
              $this-&gt;load-&gt;view("master_data/view_master_data_nav");
              $this-&gt;load-&gt;view("master_data/view_content_master_data_manage_customers",$data);
              $this-&gt;load-&gt;view("master_data/view_master_data_footer");
  
  
              $editcustomer = $this-&gt;input-&gt;post('editcustomer');
  
              // single update - working
  
              if( $this-&gt;input-&gt;post('editcustomer') != false )
              {
                  foreach ($editcustomer as $row_id)
                  {
                      $data = array( 
                          'postalcode' =&gt; $this-&gt;input-&gt;post('postalcode_'.$row_id),
                          'customer_name' =&gt; $this-&gt;input-&gt;post('customer_name_'.$row_id) );
                      $this-&gt;model_master_data-&gt;update_customer_records( $row_id, $data );
                  }
               $this-&gt;session-&gt;set_flashdata('dbaction', 'Selected Records have been updated successfully');
              redirect('masterdata/manage_customers', 'refresh');
              }
  
  
      }
  </code></pre>
  
  <p>How do I make use of the codeigniter validation class to ensure the users modify the input boxes with credible data?</p>
  
  <p>How can the</p>
  
  <p><code>$this-&gt;form_validation-&gt;set_rules("primary_contact_tell","</code>Contact Person tell<code>","required|xss_clean|min_length[10]|max_length[14]");</code></p>
  
  <p>reference the correct dynamic name of the input field? form currently has only customer name and postal code but need to add the rest of the fields.</p>
  
  <p>Thanks in advance, as always.</p>