March 10 2013

Yii rules numerical minimum or maximum display error message

Tagged Under :

Yii
Normally in Yii model rules validation to set the error message like below:
array('username', 'required', 'message'=>'username cannot blank.');

But, numerical validate method is different if you set the ‘min‘ or ‘max‘ inside the rules.

Below example are show you how to set the message for ‘min‘ and ‘max‘.
array('size', 'numerical', 
	'integerOnly' => true,
	'min' => 1, 
	'max' => 10, 
	'tooSmall' => 'size at least 1',
	'tooBig' => 'size cannot more then 10', 
)

Make a Comment

*

code