/** * Provides a form so that project administrators can * associate other users to the project */ public function actionAdduser($id) { $project = $this->loadModel($id); if (!Yii::app()->user->checkAccess('createUser', array('project' => $project))) { throw new CHttpException(403, 'You are not authorized to perform this action.'); } $form = new ProjectUserForm(); // collect user input data if (isset($_POST['ProjectUserForm'])) { $form->attributes = $_POST['ProjectUserForm']; $form->project = $project; // validate user input if ($form->validate()) { if ($form->assign()) { Yii::app()->user->setFlash('success', $form->username . " has been added to the project."); //reset the form for another user to be associated if desired $form->unsetAttributes(); $form->clearErrors(); } } } $form->project = $project; $this->render('adduser', array('model' => $form)); }