CodeIgniter Forums

Full Version: Validation of custom data (not $_POST)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

I need some advice.

I'm from Brazil and here we use differente formats for dates and numbers.
So when the user post some data I need to convert it before validation.

Problem is I'm using set_data and when I call set_value back in the form, codeigniter gets converted data and not the original posted data.

Is this correct and I need to convert back before call set_value or I'm missing something?

Thanks
Hi,
You can do evertyhing before validation to check formats :
- first : with your html tags (exampe: <input type="numeric" .../>)
- 2ndly : with javascript tests on submit
- 3rst : php with functions of Codeigniter (form_validation) or php basics functions (is_numeric, is_... or filter_input) .
You can use CI's form validation to format data as well. Create a custom rule or callback and instead of returning a TRUE/FALSE from the validation rule, return the new value.

http://www.codeigniter.com/user_guide/li...pping-data
(09-06-2015, 10:25 AM)CroNiX Wrote: [ -> ]You can use CI's form validation to format data as well. Create a custom rule or callback and instead of returning a TRUE/FALSE from the validation rule, return the new value.

http://www.codeigniter.com/user_guide/li...pping-data

Thanks! You suggestion seems like what I need.