UserMasterController 代码:
public function actionUpdate($id){
$model=$this->loadModel($id);
if(isset($_POST['UserMaster'])){
$model->attributes=$_POST['UserMaster'];
$model->attributes['emailsent'] = 'N';
if($model->save())
$this->redirect(array('admin'));
}
$this->render('update',array(
'model'=>$model,
));
}
给我一个错误的行是:
$model->attributes['emailsent'] = 'N';
ERROR : Indirect modification of overloaded property
UserMaster::$attributes
has no effect
如何更改属性值?我只想把它设置为
'Y'
或 'N'
根据条件
最佳答案
使用 $model->emailsent='N';
.就这样
关于controller - 如何更改 Controller 中的 $model->attributes 值 - Yii,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10511533/