CodeIgniter Forums
Form Validation Errors (Grouping) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Validation Errors (Grouping) (/showthread.php?tid=26730)



Form Validation Errors (Grouping) - El Forum - 01-21-2010

[eluser]RS71[/eluser]
Hello

How could I group certain form validation errors together so the errors returned are not repetitive?

What I mean is -- lets say the user submits a blank form, instead of displaying "The ABC field is required." over and over for every field in the form, how can I just say "Every field in the form is required." in the case of the 'required' rule for example.

I'd appreciate if anybody could point me in the right direction.

Thanks in advance.


Form Validation Errors (Grouping) - El Forum - 01-21-2010

[eluser]frist44[/eluser]
create a callback function that checks each field in the form and set the message to whatever you want it to say. Associate it with any field in the form and it will run and do whatever you code it to do.

IE.

function form_check() {

if (!$this->input->post('textfield1')) return FALSE;
if (!$this->input->post('textfield2')) return FALSE;

return TRUE;
}