/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Param(); if (isset($_POST['Param'])) { $model->attributes = $_POST['Param']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new param or saves the modified one. */ public function save_param() { $this->check_authorization(); $param = new Param(); $param->id = $this->get_arg('id', 0); $param->name = $this->get_arg('name', ''); $param->category_id = $this->get_arg('category_id', 0); try { $param->save(); return new Redirect('/edit_category?id=' . $param->category_id); } catch (Exception $e) { $data['error'] = $e->getMessage(); $data['param'] = $param; return new View('param_form', $data); } }