I have a form like this:
<form action="" method="post">
<input type="hidden" name="ndetails" value="<?php echo $ndetails; ?>"/>
<?php
for ($i=1; $i<=$ndetails; $i++)
{
?>
<textarea name="mydetails[]"></textarea>
<?php echo form_error('mydetails[]'); ?>
<?php
}
?>
</form>
and in the controller, I use a form validation like this:
for ($i=1; $i<=$this->input->post('ndetails'); $i++)
{
$this->form_validation->set_rules('mydetails[]', 'Day '.$i, 'trim|required');
}
the problem is when there's more than 1 textarea, the form_error('mydetails[]') only show the last error message. how can I show the errors individually after each textarea?
<textarea name="mydetails[<?php echo $i ?>]">...,<?php echo form_error('mydetails['.$i.']'); ?>,$this->form_validation->set_rules('mydetails['.$i.']', 'Day '.$i, 'trim|required');