Codeigniter - display a separate error message for array fields

Each customer has individual information. Here is a very simple example.

<input type="text" name="customer_names[]" />

Codeigniter requires every customer_name
$this->form_validation->set_rules('customer_names[]','Customer Names','required');

If any of the client names is empty, validation_errors();displays one message for the entire array.

How can I get separate error messages for this client?

NOTE. echo form_error('customer_names[0]');is what I'm trying to achieve when username 0 is left blank.

+5
source share
2 answers

Validation, Names, , , form_error() .

, , form_error('customer_names[0]') , customer_names[0].

+1

CodeIgniter 2.1.3. :

:

<input type="text" name="customer_names[0]" />
<input type="text" name="customer_names[1]" />
...

:

$this->form_validation->set_rules('customer_names[0]','Customer Names','required');
$this->form_validation->set_rules('customer_names[1]','Customer Names','required');
...

:

echo form_error('customer_names[0]');
echo form_error('customer_names[1]');
...

0

All Articles