下面的模型扩展了 CFormModel,我需要向它提及规则,以便属性只允许整数。
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),
);
}
文本字段是使用 -
<?php echo $form->textField($model,'min_size', array('placeholder' => 'Min Sqft', 'style'=>'width:100px')); ?>
但是,上述验证不起作用。如何验证文本字段以仅允许整数。无论如何我可以进行验证