public function actionAdd() { $model = new Snippet(); $data = Yii::app()->request->getPost('Snippet'); if ($data) { $model->setAttributes($data); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('add', array('model' => $model)); }