I have a form with following structure:
Field A: <input name="something[34]"> -- Field B: <input name="something_else[11]">
Field A: <input name="something[93]"> -- Field B: <input name="something_else[67]">
Field A: <input name="something[5]"> -- Field B: <input name="something_else[212]">
...
...
and so on with undefined number of rows and indexes values inside.
I cannot figure it out how to validate. I am trying different ways but I cannot guess it:
$this->form_validation->set_rules('something[]', 'Something', 'required|xss_clean');
$this->form_validation->set_rules($_POST[something[]], 'Something', 'required|xss_clean');
$this->form_validation->set_rules($_POST[something][], 'Something', 'required|xss_clean');
and so on..
I cannot figure it out how to manage it following the documentation of the form validation section. Can you give me some help with this? Thank you in advance!
I save the fields back in the DB with foreach:
foreach ($_POST['something'] as $something_id => $something_name) {
if ($this->form_validation->run() === TRUE) {
//insert
}
}