mahe211
(Mahesh Jagadale)
September 4, 2014, 6:46am
1
Hi Guys,
I am new for Yii, I want to add custom rules for form validation, in short, I have to compare the text field value with database values, whether these values are less than, greater than, equal.
Please let me know if you have any idea.
Thank you in advance.
Gregurco
(Gregurco Vlad)
September 4, 2014, 7:24am
2
mickgeek
(Olegbelostotsky)
September 4, 2014, 8:00am
3
Declaring Validation Rules
mahe211:
Hi Guys,
I am new for Yii, I want to add custom rules for form validation, in short, I have to compare the text field value with database values, whether these values are less than, greater than, equal.
Please let me know if you have any idea.
Thank you in advance.
In Rules
array("password","validatePassword"),
Your custom method
public function validatePassword($attribute,$params){
//Your logic here.
if( empty($this->password))
{
$this->addError($attribute, 'Password cannot be blank'));
}
}