Beispiel #1
0
 /**
  * Show category edit and create
  * @param int|null $id
  * @return string
  * @throws \Ffcms\Core\Exception\SyntaxException
  * @throws \Ffcms\Core\Exception\NativeException
  */
 public function actionCategoryupdate($id = null)
 {
     // get owner id for new rows
     $parentId = (int) $this->request->query->get('parent');
     // get relation and pass to model
     $record = ContentCategory::findOrNew($id);
     $isNew = $record->id === null;
     $model = new FormCategoryUpdate($record, $parentId);
     // if model is submited
     if ($model->send() && $model->validate()) {
         $model->save();
         // if is new - redirect to list after submit
         if ($isNew) {
             $this->response->redirect('content/categories');
         }
         // show notify message
         App::$Session->getFlashBag()->add('success', __('Category is successful updated'));
     }
     // draw response view and pass model properties
     return $this->view->render('category_update', ['model' => $model]);
 }