/** * Add a new page action */ public function actionCreate() { // Check Access checkAccessThrowException('op_custompages_addpages'); $model = new CustomPage(); if (isset($_POST['CustomPage'])) { $model->attributes = $_POST['CustomPage']; if (isset($_POST['submit'])) { if ($model->save()) { fok(at('Page Created.')); alog(at("Created Custom Page '{name}'.", array('{name}' => $model->title))); $this->redirect(array('custompages/index')); } } else { if (isset($_POST['preview'])) { $model->attributes = $_POST['CustomPage']; } } } $roles = AuthItem::model()->findAll(array('order' => 'type DESC, name ASC')); $_roles = array(); if (count($roles)) { foreach ($roles as $role) { $_roles[AuthItem::model()->types[$role->type]][$role->name] = $role->name; } } // Add Breadcrumb $this->addBreadCrumb(at('Creating New Page')); $this->title[] = at('Creating New Page'); // Display form $this->render('form', array('roles' => $_roles, 'model' => $model)); }
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)); }