Welcome Guest, Not a member yet? Register   Sign In
Form Validation Rule Groups errors...
#1

[eluser]tjtyrrell[/eluser]
Please forgive me in advance if I am just missing something. I have no clue what is going wrong.

So I want to have 2 rule groups on a specific page and one or the other will be called based on user input.

In my controller I first declare and set the rules
Code:
$config = array(
    'empty' => array(
            array(
                'field' => 'first_name',
                'label' => 'First Name',
                'rules' => 'trim|max_length[0]'
            )
        ),
    'valid' => array(
            array(
                'field' => 'first_name',
                'label' => 'First Name',
                'rules' => 'trim|required'
            )
        )
    );
$this->form_validation->set_rules($config);

Then I try to call one of the groups:
Code:
$this->form_validation->run('valid');

I've found that the code breaks without warning if you have faulty "rules", but I've tested my rules by creating a $config array without the rule groups and they work (any typos in here are because of trying to edit it in a textarea).

(non-rule grouped $config array)
Code:
$config = array(
    array(
        'field' => 'first_name',
        'label' => 'First Name',
        'rules' => 'required'
        )
);

So:
When setting the rules in an array without declaring "groups" my rules work and the echo validation_errors(); call works when calling the "run" method. However, when creating validation rule groups I am having issues. I am trying to follow the user guide but have been racking my brain for hours trying to figure this out on my own, and now need help.

Also, when var_dumping $errors = validation_errors(); I get an empty string... and when if-else testing on the run sequences, the forms do not pass under any circumstances.

Please note:
1) When trying to call the form_validation run() command with rules I use the rule group name I've created (e.g. $this->form_validation->run('valid'); )
2) Thinking that there might be some name conflicts I renamed the groups to random names and they are still not working
3) Currently I am only making 1 rule, I used to have about 8, but with this issue I reduced it to 1 to try and minimize user-errors.

I hope I've divulged enough information. I'm assuming it's just something small that I am completely overlooking. Thank you in advance for any and all help!


Messages In This Thread
Form Validation Rule Groups errors... - by El Forum - 05-16-2011, 06:08 PM
Form Validation Rule Groups errors... - by El Forum - 05-17-2011, 12:32 AM
Form Validation Rule Groups errors... - by El Forum - 05-17-2011, 09:15 AM
Form Validation Rule Groups errors... - by El Forum - 05-17-2011, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB