I’m new to Yii framework. Now I’m using two textfields for
min size
and
max size
. Now this textfields are supposed to take only integers. But they are taking alphabets also. I used the following rule in model file.
public function rules() {
return array(
array('min_size, max_size', 'numerical', 'integerOnly'=>true));
}
But this seems to be not working, no error is displayed . How can i validate successfully, by displaying error when text is entered. Should I make some changes in main.php
Yes, the action is the function in the controller that processes the request.
Where are your errors being output in the view?
You may want to add the $this->performAjaxValidation($model) functionality to the action, assuming that you’ve configured the form to use ajax validation.
Okay, but you should have code which is attempting to output errors in the view. Even if ajax validation isn’t working, the errors should be output on page reload. Try using this somewhere in your view:
<? echo CHtml::errorSummary($model); ?>
Also, as far as I can see, you’re not performing any validation in your action on a regular page request, which is very dangerous. Make sure that you validate the model before using any of the submitted form data.