I try to build a user management system. for that i need a form to create a new user. it’s working fine untill i build in a second password field “ConfirmPassword”.
on submit i get the error: Property "User.PasswordConfirm" is not defined.
i think yii is giving me the error because the field doesn’t exist in the database.
how can i get this working?
below the code:
User model:
public function rules()
{
return array(
array('GroupId, FirstName, LastName, Email, Username, Password, PasswordConfirm', 'required'),
array('Email', 'email'),
array('Password', 'compare', 'compareAttribute' => 'PasswordConfirm')
);
}
public function safeAttributes()
{
return array('GroupId', 'FirstName', 'LastName', 'Email', 'Username', 'Password', 'PasswordConfirm');
}
You can use it in the rules as required if they need to check it, another way is to use the parameter checked on your checkbox, this way it’s auto checked and users have to select or deselect it.