4

UserMasterController Code:

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,
    ));
}

the line which gives me an error is : $model->attributes['emailsent'] = 'N';

ERROR : Indirect modification of overloaded property UserMaster::$attributes has no effect

How can I change the attribute value ? I just want to set it as 'Y' or 'N' as per the condition

tereško
  • 58,060
  • 25
  • 98
  • 150
Darshit Gajjar
  • 746
  • 4
  • 13
  • 26

2 Answers2

12

Use $model->emailsent='N';. Thats all

dInGd0nG
  • 4,162
  • 1
  • 24
  • 37
5

Just try this $model->setAttribute($name,$value);

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
hackil
  • 71
  • 1
  • 1