Welcome Guest, Not a member yet? Register   Sign In
How many are using CI's built in form validation?
#1

[eluser]jleequeen[/eluser]
I'm trying to get a sense of how invested I should get into using CI's built in form validation. It seems these days that most web apps have some form of client side javascript validation. I realize that you need to do both client side and server side to be completely safe in case someone does not have javascript turned on. Do those of you that use client side validation just use CI's built in form validation, or do you roll your own solutions? If you are using CI's form validation, do you use one big config file for rules, or do you place the rule code in the methods of your controllers?
#2

[eluser]bretticus[/eluser]
I'm not totally in love with CI's form validation, but with the callback functionality, I find myself using it about 99% of the time (to save time which is a bigger point of using a framework.) It's okay if you are not comparing form data (of more than two fields at least.) 99% of the time, my form validation is checking one form input at a time.

You're right. You should do a server-side version of validation and then come back and do a javascript version. In situations were I have gone this route, I use ajax (jquery $.post or $.get) to validate against the same controller method where my form action points. I make use of the IS_AJAX constant (google it) and form validation's undocumented error array to send any errors back to my page.

This blog posts shows an example of more or less what I do.
#3

[eluser]Victor Michnowicz[/eluser]
I second what Brett said. I am not totally in love with it either. But the callback functionality is really handy.

One way to check multiple values in one callback:

Code:
function dive_check($drive)
{
    $age = $this->input->post('age');
    
    if ( ($drive  == 'yes') AND ($age < 16) )
    {
        $this->form_validation->set_message('dive_check', 'You are less than 16, you can not drive!');
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}
#4

[eluser]pbreit[/eluser]
Do other frameworks do form validation better? If you don't use CodeIgniter's do you end up just coding it all from scratch? Do you use any helpers?




Theme © iAndrew 2016 - Forum software by © MyBB