public function actionUpdate($id) { $assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/../assets/'); Yii::app()->getClientScript()->registerScriptFile($assetsUrl . '/accessForm.js'); $model = new Access(); $model = $this->loadModel($id); if (isset($_POST['Access'])) { $model->setAttributes($_POST['Access']); if (isset($_POST['Access']['roles'])) { $model->roles = $_POST['Access']['roles']; } else { $model->roles = array(); } try { if ($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('/role/access')); } } } catch (Exception $e) { $model->addError('', $e->getMessage()); } } //if module is selected from drop down, set it to model and nullify controller from old module if (isset($_GET['module'])) { $model->module = $_GET['module']; $controllers = Awecms::getControllers($model->module); $model->controller = reset($controllers); } //if controller is selected from dropdown set it to model if (isset($_GET['controller'])) { $model->controller = $_GET['controller']; } $this->render('update', array('model' => $model)); }