I have a table like this:
(id, name, version, text).
(name, version) is unique key, how can i make a rule to validate this.
I have a table like this: (id, name, version, text). (name, version) is unique
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This can be done by Yii itself, you do not need an extension for it.
However an extension can help cleaning up the
rules()method as described here:http://www.yiiframework.com/extension/unique-attributes-validator/
This is the code (copied from that site) which will work without using the extension:
In case the value of
$this->secondKeyis not available insiderules()-method you can add the validator in CActiveRecordsbeforeValidate()-method like this: