• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating from 1.6.3 to 2.1.0 - getting validated POST data

#1
[eluser]potion[/eluser]
I've been away from CI for a while, apologies if this is obvious.

I'm updating a site from CI 1.6.3 to 2.1.0

Getting POST data using the old validation class used something like:

Code:
$my_form_field = $this->validation->my_form_field;

With the replacement form_validation class is it sufficient to simply use:

Code:
$my_form_field = $this->input->post('my_form_field');


#2
[eluser]dallen33[/eluser]
Should be okay, but you might want to read up on the guide:

http://ellislab.com/codeigniter/user-gui...ation.html

#3
[eluser]InsiteFX[/eluser]
Also check these ./application/config/config.php:
Code:
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/

$config['csrf_protection']  = FALSE;
$config['csrf_token_name']  = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire']      = 7200;

#4
[eluser]potion[/eluser]
[quote author="dallen33" date="1329072872"]Should be okay, but you might want to read up on the guide...[/quote]
Surprisingly, the guide does not show an example of using the POST data.

My assumption is that the method form_validation->run() reads and validates the POST data, and the method subsequently used to fetch the POST data is arbitrary. The old validation->run() also worked on the POST data, but using $this->validation->my_form_field validated the field again, and was deemed redundant.

I think it's safe to use $this->input-post(my_form_field) without fear of the reworked 2.1.0 code being any less robust than it's predecessor.

< : ) den


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.