The below model extends CFormModel and I need to mention rules to it such that the attributes allow only integers.
class SearchForm extends CFormModel {
public $min_size;
public $max_size;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules() {
array('min_size, max_size', 'numerical', 'integerOnly'=>true),
);
}
The textfield is created using -
<?php echo $form->textField($model,'min_size', array('placeholder' => 'Min Sqft', 'style'=>'width:100px')); ?>
But, the above validation is not working. How can I validate the text field to allow integers only. Is there anyway I can do validation
try this
public function rules(){
return array(
array('min_size, max_size', 'numerical', 'integerOnly'=>true));}