trim|valid_email not working in validation |
Yea, that can't possibly work.
It's not magic, you know ... The FV library modifies the $_POST array, and you have copies of its values assigned before they are modified. To get the modified values, assign to $this->data after the validation runs.
OK that explains it. To me, however this should be more clear in the documentation. It is not obvious that native PHP functions wont work on the data I specify with the set_data() method. Anyway, thanks a lot.
Yea, set_data() was added to an already complete library and details like this have slipped through. CI 3.2 will indeed address this, although differently than you would imagine.
Firstly load form_validation library after that use set_rules
Check this code for valid email $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'Email address', 'trim|required|valid_email'); (01-08-2018, 11:37 PM)XtreemDeveloper Wrote: Firstly load form_validation library after that use set_rules The problem was when I also use set_data(). Then trim do not work on the data as I expected. Case closed. Thanks. |
Welcome Guest, Not a member yet? Register Sign In |