public function actionRemoveUser($id) { $model = $this->loadModel($id); $pieces = explode(', ', $model->assignedTo); $pieces = Sales::editUsersInverse($pieces); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Sales'])) { $temp = $model->attributes; $model->attributes = $_POST['Sales']; $arr = $_POST['Sales']['assignedTo']; foreach ($arr as $id => $user) { unset($pieces[$user]); } $temp = Sales::parseUsersTwo($pieces); $model->assignedTo = $temp; $changes = $this->calculateChanges($temp, $model->attributes); $model = $this->updateChangelog($model, $changes); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('addUser', array('model' => $model, 'users' => $pieces, 'action' => 'Remove')); }