If I may add something, take care that when the user wants to update his/her email, the 'unique' validator is not appropriate and you could use a scenario based rule like for instance :
(example below would be for a name update …but the principle is tha same than for email)
where ValidateUniqueName would be defined as a method:
public function ValidateUniqueName($attribute,$params)
{
$exist=User::model()->exists('name=:name and id!=:ID',
array(
':name' => $this->name,
':ID' => $this->id
)
);
if($exist)
{
$this->addError($attribute,'this name is already used');
}
}
I think this is the correct way to handle this situation and as I had to deal with it already, thought it may be useful to you.
Yes, what you discuss is right. Actually I was getting errors when updating. However, I think the problem is related to the fact that I copied the create action code into the update action because I deleted it initially by thinking I am editing the create action. Now, I am having informatics class at school, so I can't check the code at home, so will check it and provide my feedback. Actually, it would be good if I am able to use action-based validators.