I have two tables table1 and table2 each having a column named email along with different other columns. What I want is a validator which looks for uniqueness in email field of both the columns. I found an extension which checks multiple columns of SAME table. How can I extend it so that it works for multiple columns?
I have two tables table1 and table2 each having a column named email along
Share
You can use className property to specify for other classes..
Documentation:
the ActiveRecord class name that should be used to look for the attribute value being validated. Defaults to null, meaning using the class of the object currently being validated. You may use path alias to reference a class name here.Lets have an attribute called common_attr in two models:
And to check
combined keyvalidation from multiple tables you can use criteria property of CUniqueValidator.. No need for any extensionDocumentation:
criteria propertypublic array $criteria;
additional query criteria. This will be combined with the condition that checks if the attribute value exists in the corresponding table column. This array will be used to instantiate a CDbCriteria object.