I have 2 fields (person1, person2)
I want to check on rules if the person1 is equal person2.
I tried something like that:
Added on rules
array('id_person1', 'same', $this->id_person2),
Created a method
public function same($attribute,$params)
if($this->$attribute == $params)
$this->addError($attribute, 'You cannot set the same responsavel');
but it dont work, i don’t know how to create that validation.
Someone can help me.
I can do that in the controller, but i think it’s more correct to do that on the model.
Look at the ‘compare’ validator. Already built.
But i want to check it on the create/update not on the search.
I need to validate it on the form, how i add a rule to check it using compare?
I believe waitforit meant this (see also here), and not the CDbCriteria compare method.
And maybe see this wiki.