![]() |
Form validation and Checkboxes - 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 and Checkboxes (/showthread.php?tid=2017) |
Form validation and Checkboxes - El Forum - 07-11-2007 [eluser]Unknown[/eluser] Hello everyone, I'm a new user in CI, but i definitely love it!! I used CI (form validation) with 2 checkboxes and these use the same name, different values. The rules i applied to the checkboxes was isset|callback_checkboxes, but when i submit the form i saw that validation doesn't create the variable $this->validation->checkboxname_error. Therefore i look into the validation class and i write these lines at line number 231: // Build the error message $mfield = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field]; $message = sprintf($line, $mfield); // Set the error variable. Example: $this->username_error $error = $field.'_error'; $this->$error = $this->_error_prefix.$message.$this->_error_suffix; $this->_error_array[] = $message; Instead of these lines: $field = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field]; $this->_error_array[] = sprintf($line, $field); Now the $this->validation->checkboxname_error is available. I hope i've done something usefull. Bye Cristiano aka Il Viaggiatore Form validation and Checkboxes - El Forum - 10-12-2007 [eluser]fry-guy[/eluser] Thank you for much for this hack!! It's an absolute life saver!! Thanks again! ![]() Form validation and Checkboxes - El Forum - 10-14-2007 [eluser]Unknown[/eluser] im glad it has been useful ;-) Form validation and Checkboxes - El Forum - 11-03-2007 [eluser]codex[/eluser] Thank you so much! I was breaking my head over this one. |