This is a little bit stupid but I would really appreciate your help. I cannot save the user id of the user I am currently updating to my database.
I have a table classification with ‘id’, 'user_id, ‘class_name’ columns. ‘user_id’ is foreign_key to user table. Now, I am logged in as a user secretary and what i would try to do is to assign new classification to other user. I successfully add their class but their id did not save to my db. ‘user_id’ is returning NULL. how can I save the user_id of the user I am assigning new classification?
This is my controller:
public function actionAssignClass($id)
{
$model=$this->loadModel($id);
$options=new OptionRecord();
$model= new User;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
$model->classification = $options->getCategoryatIndex($model->classification);
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$model->classification = $options->getCategoryIndex($model->classification);
$this->render('assignClass',array(
'model'=>$model,
));
}