[eluser]CrustyDOD[/eluser]
Hey!
Imagine a form field, checkboxes with name="something[]"
Form validation
Code:
$this->form_validation->set_rules('something[]', 'something', 'callback__checkValues');
_checkValues function queries table to check if selected item really exist.
Now let's say you have a form with around N checkboxes per page. User selects ALL checkboxes,
and submits the form.
Result = N queries because form_validation loops over something[] array and calls the rules each time which is fine until
you have a situation like above with sql involved..
How would you guys solve this to make 1 query like:
Code:
SELECT ... IN ('something[]')
The only way i can think of is to call a function like:
Code:
if ($this->form_validation->run() == TRUE)
{
if (someFunction($this->input->post('something[]')) == FALSE)
{
// set error message and save it to session
// refresh page
}
// form was successfully submitted code here..
}
Is there a better way?