Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Validation prep functions do not work... #195

Open
gcoultrip opened this issue Feb 13, 2015 · 0 comments
Open

Form Validation prep functions do not work... #195

gcoultrip opened this issue Feb 13, 2015 · 0 comments

Comments

@gcoultrip
Copy link

(Codeigniter 3.x)
...this is because the Form Validation library runs prep functions (like trim(), strtolower() ... etc) on the $_POST array values.

Fix: Re-populate the $data array with the $_POST values after running form validation within MY_Model. This could be achieved by adding the following code to the MY_Model validate() method - after running form_validation->run() and before returning $data:

foreach($_POST as $key => $val)
{
    if (array_key_exists($key, $data))
    {
        $data[$key] = $val;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant