EllisLab text mark
Advanced Search
     
Best way for getting form values
Posted: 04 October 2012 03:40 AM   [ Ignore ]
Avatar
Joined: 2012-04-02
85 posts

Guys,

Just wondering if you can explain me the difference between these two way for getting values on form submission:

$this->form_validation->set_value('login'

&&

$this->input->post('login'

Both works perfectly but dont know which is the difference.

Thanks,
Cheers!

 
Posted: 04 October 2012 04:10 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-25
1007 posts

“set_value” is used when repopulating form values
in case the form_validation failed. You echo it
in the “value” attribute of your form field.

To get the submitted form data and process it in
your controller use

$my_value $this->input->post('name_form_field'); 
 
Posted: 04 October 2012 10:29 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2012-04-02
85 posts

Thanks,

yeah, that’s the way I do it but checking the Tank_auth code I just realized that it does it (catch values in the controller after form submission) using the first one method:

$this->form_validation->set_value('login'

I’m just asking cause really don’t know if doing it that way gain/lose something, i don’t know.

Cheers!

 
Posted: 04 October 2012 10:48 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-25
1007 posts
$this->form_validation->set_value('login'

Afaik this line is just to SET the value. If you look
at the code in tank auth it’s not processed furthermore.
I don’t know why he had this at all because if you run
the form_validation all values of the fields defined in
the rules are set automatically.