Answer the question
In order to leave comments, you need to log in
YII. Why is the validator not working?
There is a form for uploading files, described in the model, here are the validation rules:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('folder_id, file_name, file_txt', 'required'),
array('folder_id', 'numerical', 'integerOnly'=>true),
array('file_name', 'length', 'max'=>128),
array('file_txt', 'file',
'allowEmpty' => false,
'types'=>'txt',
'maxSize'=>1024 * 1024, // 1 MB
'tooLarge'=>'File is too large!',
),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('file_id, folder_id, file_name', 'safe', 'on'=>'search'),
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question