August 29 2016

Yii2 number compare validation rules

Tagged Under :

In Yii2 compare two numbers attributes in operator function. you will found that it not working properly. This is because the wrongly “type” in compare validation rules.

You may need to set the type to number as below:
'type' => 'number'
['min_price', 'compare', 'compareAttribute' => 'max_price', 'operator' => '<', 'type' => 'number'],

Make a Comment

You must be logged in to post a comment.