public function actionCreate() { $model = new Menu(); $form = new Form('content.MenuForm', $model); if ($form->submitted() && $model->save()) { $section = new MenuSection(); $section->menu_id = $model->id; $section->title = $model->name . '::корень'; $section->saveNode(); $this->redirect('/content/MenuAdmin/manage/'); } $this->render('create', ['form' => $form]); }
public function actionManage($menu_id) { $menu = Menu::model()->findByPk($menu_id); if (!$menu) { $this->pageNotFound(); } $root = MenuSection::model()->roots()->find('menu_id = ' . $menu_id); if (!$root) { $root = new MenuSection(); $root->menu_id = $menu->id; $root->title = $menu->name . '::корень'; $root->saveNode(); } $model = new MenuSection('search'); $model->unsetAttributes(); if (isset($_GET['MenuSection'])) { $model->attributes = $_GET['MenuSection']; } $this->render('manage', ['menu' => $menu, 'model' => $model, 'root' => $root]); }