简体   繁体   中英

CakePHP Validation not working on password

This seems to have popped up various times for others but I have seen no real explanation of the issue or what the fix is.

So basically I have some validation like:

var $validate = array(
    'password' => array( 
        'rule' => 'notEmpty',
        'message' => 'You must create a password'
    )
);

However:

1.) the validation message does not show? 2.) and on the postback the password field becomes filled with the validation rule???

Can anyone help?

Thanks

did you try:

var $validate = array(
    'password' => array( 
        'notEmpty' => array( 
            'rule' => 'notEmpty',
            'message' => 'You must create a password'
        )
    )
);

it uses the full validation array structure.

also you shoudnt use "password" as name. there are many tricks to avoid issues with this since in cake1.2 there is automatic going on which can cause strange things. For example use pwd and set it to password on save.

tip: use a behavior for it: http://www.dereuromark.de/2011/08/25/working-with-passwords-in-cakephp/ this saves you a lot of trouble

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM