Hi again to everyone =), i have a new problem with uploading image, i can upload the image with create action, but my problem is when i want update, i wanna can update my db table without new image, but ever say me image cannot be blank, i dont have the image field required…
Model code:
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
//.......
array('dni, nom, cognoms, adresa, data_naiximent, telefon_1, correu_electronic, lloc_naiximent, poblacio', 'required'),
array('foto', 'unsafe'),
array('foto', 'file', 'types'=>'jpg, gif, png'),
array('dni', 'ext.MyValidators.dniValidate'),
//.......
);
}
Controller code (update)
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Persona']))
{
$model->foto=CUploadedFile::getInstance($model,'foto');
$name = 'images/personas/'.md5(time()).'_'.$this->normalizar_nombre($model->foto);
$foto_ = $model->foto;
$model->attributes=$_POST['Persona'];
$model->foto = $name;
if($model->save())
{
$foto_->saveAs($name);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('update',array(
'model'=>$model,
));
}
I tried with this comment in this wiki http://www.yiiframework.com/wiki/2/ but it give me the same error
[b]Grettings and thanks,
s0mk3t[/b]