Пример #1
0
 /**
  * Updates an existing Page model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'layouts' => Page::getLayouts(), 'templates' => Page::getTemplates(), 'active' => Page::getActiveList()]);
     }
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['name'], 'string', 'max' => 64], [['title'], 'string', 'max' => 128], [['text'], 'string'], [['layout'], 'string', 'max' => 64], [['template'], 'string', 'max' => 64], [['description', 'keywords'], 'string', 'max' => 256], [['language'], 'string', 'max' => 8], [['name', 'title'], 'required'], [['name'], 'unique', 'targetAttribute' => ['name', 'language']], [['active'], 'in', 'range' => array_keys(Page::getActiveList())]];
 }