以下のモデルは 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')); ?>
しかし、上記の検証は機能していません。整数のみを許可するようにテキスト フィールドを検証するにはどうすればよいですか。とにかく検証を行うことができますか