Welcome Guest, Not a member yet? Register   Sign In
trim|valid_email not working in validation
#11

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.
Reply
#12

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.
Reply
#13

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.
Reply
#14

OK, I'll manage. Thanks Narf!
Reply
#15

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');
Reply
#16

(01-08-2018, 11:37 PM)XtreemDeveloper Wrote: 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');

The problem was when I also use set_data(). Then trim do not work on the data as I expected. Case closed. Thanks.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB