Hi
Apologies in advance, but I think I’ve starred at this for far too long and can’t figure-out what I’ve done wrong.
All fields in the DB update on update apart from the "image" field!!
Any help great fully received.
public function rules()
{
return array(
array('room, s_order, item, description', 'required'),
array('room', 'length', 'max'=>50),
array('item', 'length', 'max'=>50),
array('image', 'length', 'max'=>500, 'on'=>'insert,update'),
array('description, comment, x_comment', 'length', 'max'=>5000),
array('image','file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'on'=>'update'),
array('invpath', 'length', 'max'=>5000),
array('id, inv_id, room, item, description, comment', 'safe', 'on'=>'search'),
);
}
public function actionUpdate($id)
{
$model=$this->loadModel($id);
if(isset($_POST['InventoryLine']))
{
$_POST['InventoryLine']['image'] = $model->image;
$model->attributes=$_POST['InventoryLine'];
$uploadedFile=CUploadedFile::getInstance($model,'image');
if(empty($uploadedFile))
$fileName = $model->image;
else
$fileName = date("d-m-Y-h-i-s", time()).".jpg";
if($model->save())
{
if(!empty($uploadedFile))
{
$uploadedFile->saveAs(Yii::app()->basePath.'/../uploads/inventory/site/'.$fileName);
chmod(Yii::app()->basePath.'/../uploads/inventory/site/'.$fileName, 0777 );
}
}
$this->redirect(array("inventory/view",'id'=>$model->inv_id));
}
$this->render(‘update’,array(
‘model’=>$model,
));
}