Welcome Guest, Not a member yet? Register   Sign In
Validating a field that is an Array
#1

[eluser]polaris1927[/eluser]
Hi,

I would like to know how I can validate an array field.

The contact_number needs to be an array of phone numbers and in my view code, I use a for loop to display the array contents.

My problem is how to define the
Code:
$fields['contact_number']
in the validation code.


Below is my code that does not work:

My Controller has the following code:

Code:
$fields['contact_number[]'] = "phone number";

My view has the following:
Code:
&lt;?php for($i=0; $i < 5; $i++): ?&gt;
  <tr>
      <td width="10%" style="text-align: center;">&lt;?php echo $i + 1; ?&gt;</td>
      <td width="59%">&lt;?php echo $this->formatnumber->format( $this->validation->contact_number[$i] ); ?&gt;</td>
      <td width="10%"></td>
      <td width="10%"></td>
    </tr>
&lt;?php endfor; ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB