public function actionAdd() { $model = new CustomPage(); $this->editSectionName = "Add a new custom page"; if (isset($_POST['CustomPage'])) { $model->setPageData($_POST); $model->attributes = $_POST['CustomPage']; if ($model->validate()) { if (!$model->save()) { Yii::app()->user->setFlash('error', print_r($model->getErrors(), true)); } else { Yii::app()->user->setFlash('success', Yii::t('admin', 'Custom page added on {time}.', array('{time}' => date("d F, Y h:i:sa")))); $this->redirect($this->createUrl("custompage/edit", array('id' => $model->id))); } } } $this->render('edit', array('model' => $model)); }