public function actionAddUser($id) { $users = User::getNames(); unset($users['admin']); unset($users['']); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } $contacts = Contacts::getAllNames(); unset($contacts['0']); $model = $this->loadModel($id); $users = Sales::editUserArray($users, $model); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Sales'])) { $temp = $model->assignedTo; $tempArr = $model->attributes; $model->attributes = $_POST['Sales']; $arr = $_POST['Sales']['assignedTo']; $model->assignedTo = Sales::parseUsers($arr); if ($temp != "") { $temp .= ", " . $model->assignedTo; } else { $temp = $model->assignedTo; } $model->assignedTo = $temp; $changes = $this->calculateChanges($tempArr, $model->attributes); $model = $this->updateChangelog($model, $changes); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('addUser', array('model' => $model, 'users' => $users, 'contacts' => $contacts, 'action' => 'Add')); }