system
(system)
May 20, 2009, 9:45pm
1
Model Code
public function rules()
{
return array(
array('product_image', 'file', 'allowEmpty' => true),
);
}
With This RULE applied, only product_image attribute changes. Any modification to other attributes stay same… Is it a bug or am i doing something wrong
system
(system)
May 21, 2009, 7:18am
2
Sorry the rule i was using is
array('product_image', 'file', 'allowEmpty' => false),
This only allows the "product_image" attribute of model (Active Record) to update if change. Other attributes changed from Form are not updated in database.
…Controller CODE
public function actionCreateProduct()
{
$this->layout = "productmanagement_layout";
$product=new product;
$category = new category;
if(isset($_POST['product']))
{
$product->attributes=$_POST['product'];
$product->product_image=CUploadedFile::getInstance($product,'product_image');
if($product->save()){
$product->product_image->saveAs("images/product/$product->product_image");
$this->redirect(array('ListProduct'));
}
}
$this->render('CreateProduct',array('product'=>$product));
}
qiang
(Qiang Xue)
May 21, 2009, 12:42pm
3
Are other attributes listed in safeAttributes() of the model?