Welcome Guest, Not a member yet? Register   Sign In
bug in form_validation matches function?
#1

[eluser]Khoa[/eluser]
When I use matches in the new form_validation library with the following settings:

Code:
// Inside the application/config/form_validation.php

array(
    array(
        'field' => 'password',
        'label' => 'password',
        'rules' => 'required|min_length[5]|max_length[20]|matches[password2]|md5|trim'
    ),
    
    array(
        'field' => 'password2',
        'label' => 'confirmed password',
        'rules' => 'required'
    )
)

it produces the following error message:

"The password field does not match the password2 field."

Shouldn't it be:

"The password field does not match the confirmed password field." ?

I think it should be putting in the field label rather than the field name itself.

We probably can fix it inside the form_validation.php lib, but I don't know how (:-P), so maybe someone can help me out if they already know how to fix.

Thanks.
#2

[eluser]hostcord[/eluser]
I think if you switchthe matches rule around to be in the password2 section it will work.
#3

[eluser]Khoa[/eluser]
Oh!! Putting matches to password2 field works like a charm!! Thank you :-)
#4

[eluser]Nonox[/eluser]
Khoa.
Could you paste your fixed code in this thread? I didn't understand the solution.

Thanks.
#5

[eluser]Khoa[/eluser]
Hi Nonox,

Here is the updated code:

Code:
// Inside the application/config/form_validation.php

array(
    array(
        'field' => 'password',
        'label' => 'password',
        'rules' => 'required|min_length[5]|max_length[20]|md5|trim'
    ),
    
    array(
        'field' => 'password2',
        'label' => 'confirmed password',
        'rules' => 'required|matches[password]' // Move the 'matches' from the above array down to this array, I think you can even remove the 'required' condition because if it is empty it won't match 'password' anyway
    )
)
#6

[eluser]Nonox[/eluser]
Khoa.
Thank for your answer, If you want you can take a look to this thread about this issue.

http://ellislab.com/forums/viewthread/97065/#495036




Theme © iAndrew 2016 - Forum software by © MyBB