خرید بک لینک

Vote count: 0

How to implement custom validation in yii2?

My code in model rules is

public function rules()
    {
        retu [


            [['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?

asked 51 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 30 تير 1395 ساعت: 6:40

صفحه بندی