How to implement custom validation in yii2?
My code in model rules is
public function rules()
{
return [
[['product_price'], 'checkMaxPrice']
];
}
public function checkMaxPrice($attribute,$params)
{
if($this->product_price > 1000) {
$this->addError($attribute,'Price must be less than 1000');
}
}
Anything else I have to do in view?