Have array of customers each with individual details. Here is a very SIMPLE example.
<input type="text" name="customer_names[]" />
In codeigniter, each customer_name is required$this->form_validation->set_rules('customer_names[]','Customer Names','required');
If any of the customer names are blank, validation_errors();
shows one message for the entire array.
How can I obtain individual error messages for that customer?
NOTE: echo form_error('customer_names[0]');
is what I am trying to achieve where customer_name 0 was left blank.
Looking at the Form Validation documentation, specifically the Using Arrays as Field Names section, I think you're going to need to explicitly name your inputs
by including the index in the name to get the form_error()
method to work as you desire.
So in order for form_error('customer_names[0]')
to work, there will actually have to be an input with the name customer_names[0]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With