I have a user model. In it, I set the checks that are used when registering the user. It works great. But when a user edits his profile information, I do not want to check some fields, such as password, email address, etc. How is this possible. Below is the code.
<?php class User extends AppModel{ var $name = 'User'; // used when user registers var $validate = array( 'login' => array( 'minLength' => array( 'rule' => array('minLength', '6'), 'field' => 'login', 'message' => 'mimimum 6 characters long' ) ), 'password' => array( // don't want to validate in edit profile page 'minLength' => array( 'rule' => array('minLength', '6'), 'field' => 'password', 'message' => 'minimum 6 characters long' ) ), 'email' => array( array( 'rule' => 'email', 'message' => 'please enter a valid email address' ) ) ); ?>
Above is used when I register a user. But when the user edits his profile, I can not edit / change the user password. Therefore, each time when editing a profile, he checks the correctness of password verification. I did not add the password field to the edit profile page, I do not want to check the password field. Can I have different validation rules for different actions?
Thanks.
source share