where ValidateUniqueName would be defined as a method:
public function ValidateUniqueName($attribute,$params)
$exist=User::model()->exists('name=:name and id!=:ID',
':name' => $this->name,
':ID' => $this->id
$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.