![]() |
Form Validation - returns "(Anonymous function)" - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Form Validation - returns "(Anonymous function)" (/showthread.php?tid=70247) |
Form Validation - returns "(Anonymous function)" - sintakonte - 03-13-2018 Hey guys, i migh've found some bug. In the docs there is a section called Callable use anything as a rule I've an object where i do the following PHP Code: $this->ci()->load->model('admin/person/Cppersonsave_model'); After that i ran the Validation like PHP Code: $this->ci()->form_validation->reset_validation(); an excerpt of the model function looks like PHP Code: if ($col->count() > 0) My model function get called correctly. But if i do that an error message appears (Anonymous function) i debugged the code and got the following information In line 687 in the Form_validation Library the variable callable is set to true. On Line 741 the $rule variable gets the callable value which is a boolean and therefore true. This leads to line 799 which exactly put my message out. Am i'm missing something here or is this a bug ? Thx in advance for your answers RE: Form Validation - returns "(Anonymous function)" - jreklund - 03-13-2018 I haven't tested putting the validation inside a modal. Only in the same libraries. Maybe it can't find the form_validation if it's differs from the file initializing it. But the documentation clearly states that it should work. I'm doing it like this, querying the modal instead. PHP Code: public function login() Maybe you need to use CI() on this too: PHP Code: $this->form_validation->set_message('check_duplicates', 'This person already exists!'); RE: Form Validation - returns "(Anonymous function)" - ciadmin - 03-13-2018 The callable function needs to be outside any class; it isn't a method. You haven't shown yours. RE: Form Validation - returns "(Anonymous function)" - sintakonte - 03-14-2018 i dont understand what you mean @ciadmin but nevertheless i solved the problem and it whas on my side i needed to wrap the rule to an additional array after that it worked fine (i just thought i don't need it because i do only have one rule) so the solution was PHP Code: $this->arrValidationRules[] = array( |