Callable models in form_validation.php file |
Hi I'm using CI 3.1.11 and, at the moment I can't use callable models in my config/form_validation.php file. Can you show me the code to do that, or this can't be done??
Thanks in advance
@Omar Crespo,
Is the form_validation.php file a custom file? Why didn't you create a library (https://codeigniter.com/userguide3/gener...m%20helper) or helper (https://codeigniter.com/userguide3/gener...ng-helpers) instead?
Yes, it is the custom file, located in config folder. I don't need as much as a new library. I'm asking because in the guide it said that anything is callable, but I found i can't call a model function directly, from my custom file.
In application/config/form_validation.php
array ( 'field' => 'password', 'label' => 'Contraseña', //'rules' => array('trim','required','matches[passconf]',array('resol_127_2019',$this->user_m,'resolucion_127_2019'), 'rules' => 'trim|required|matches[passconf]|callback_res_127_2019', ), As you can see, there's a commented line, which has the call to my user_m model, but that doesn't work, so I'm using a callback function in the controller. In the guide, form_validation library, there's a section that says Callable: Use anything as a rule. The very first example is a direct call to a model. But that doesn't work for me.
Did you try to autoload the model in config/autoload.php ?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |