Welcome Guest, Not a member yet? Register   Sign In
Form Validation Class is BUGGING OUT
#1

[eluser]Braden Schaeffer[/eluser]
Here's the deal.

I've got a form validation set up to get rules from a config file. Right now, there is only one set of rules in the config file. When I call that set of rules by it's exact group name, no validation takes place at all, but when I call a validtion group that doesn't exist at all, it valdiates.

First, here's my form_validation.php config file:
Code:
<?php

$config = array(

    'beta_signup' => array(
        'field' => 'email',
        'label' => 'email',
        'rules' => 'required|valid_email',
    ),

);

Now here's an example of what doesn't work (but should):
Code:
if(!$this->form_validation->run('beta_signup'))
{    
    echo "fail";
}
else
{
    echo "pass";
}

And here's an example of what does work (but shouldn't):
Code:
if(!$this->form_validation->run('anything-but-a-real-validation-group'))
{    
    echo "fail";
}
else
{
    echo "pass";
}

The last example validates correctly, while the first example acts like an exact match is not freaking good enough. I've been staring at this for an hour or two and cannot, for the life of me, figure out what is going on with this nonsense.

Any ideas?

PS: I also tried adding another rule group to the config file, just to see if having only one group in a config file was the problem, but it's not.
#2

[eluser]Craig A Rodway[/eluser]
Comparing the documentation with your code, it looks like you're missing a sub array from your $config array.

Also try using double equals and FALSE in your comparison for the run() method, as per the documentation.
#3

[eluser]Colin Williams[/eluser]
Craig's right. You need one more dimension in your array.

Code:
$config = array(

    'beta_signup' => array(
        array(
            'field' => 'email',
            'label' => 'email',
            'rules' => 'required|valid_email',
        ),
    ),

);




Theme © iAndrew 2016 - Forum software by © MyBB