Hi,
I cannot understand the behavior of validate() of Model with rule ‘file’
In model upload I wrote:
class Upload extends CFormModel {
public $myfile;
public function rules() {
return array(
array('myfile', 'file', 'types' => 'doc'),
);
}
In controller
$model = new Upload();
$uploaded =$model->validate();
var_dump($uploaded);
$this->render('index', array('model' => $model));
In view
echo CHtml::beginForm('','post',array('enctype'=>'multipart/form-data'));
echo CHtml::error($model, 'myfile');
echo CHtml::activeFileField($model, 'myfile');
echo CHtml::submitButton('my Upload');
echo CHtml::endForm();
The strange is the var_dump($uploaded) displays the normal situation although I havent put the code “$model->attributes = $_POST[‘Upload’];” to get the attributes model by $_POST!
How the validator knows the $_POST or $_FILES variables without setting the above?
Thanks