Displays a form to create a new Menu entity.

@Route("/new", name="manage_menu_new")
@Template()
177964
public function newAction()
    {
        $entity = new Menu();
        $form   = $this->createForm('menu', $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
337299
public function newAction(Request $request)
    {
        $page = new Page();

        $form = $this->createCreateForm($page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $channel = $this->getSelectedChannel();

            $page->setChannel($channel);

            $dm = $this->getDocumentManager();

            $dm->persist($page);
            $dm->flush();

            $this->get('integrated_page.services.route_cache')->clear();

            $this->get('braincrafted_bootstrap.flash')->success('Page created');

            return $this->redirect($this->generateUrl('integrated_page_page_index', ['channel' => $channel->getId()]));
        }

        return [
            'form' => $form->createView(),
        ];
    }
806097
function create_menu($menu){
    
        $url = self::API_URI . self::MENU_CREATE;
        $param['access_token'] = $this->access_token;
        $menu_url = $this->create_url($url, $param);
    
        $fields = self::json_encode($menu);
        $data = $this->http_post($menu_url, $fields);
        return $this->return_data($data);
    
    }
520902
def new(self, request):
        """"""
        form = (self.form or generate_form(self.model))()

        return self._render(
            request = request,
            template = 'new',
            context = {
                'form': form
            },
            status = 200
        )
277842
public function createMenuItemAction(Request $request, Menu $menu)
    {
        $entity = new MenuItem();
        $entity->setMenu($menu);
        $form = $this->createMenuItemCreateForm($entity);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            if($entity->getPage()){
                $entity->setPageSlug($entity->getPage());
            }

            $em->persist($entity);

            $this->get('amulen.page.service.menu')->reorder($menu);
            $em->flush();

            $availableLangs = $this->container->getParameter('flowcode_page.available_languages');
            foreach ($availableLangs as $key => $value) {
                $menuItemLabel = new MenuItemLabel();
                $menuItemLabel->setLang($key);
                $menuItemLabel->setContent($entity->getName());
                $menuItemLabel->setMenuItem($entity);
                $em->persist($menuItemLabel);
            }
            $em->flush();

            return $this->redirect($this->generateUrl('admin_menu_items', array('id' => $menu->getId())));
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
136859
public function createAction()
    {
        /**
         * @var $form \Zend\Form\Form
         */
        $form = $this->getCreateForm();

        if ($this->getRequest()->isPost()) {
            $form->setData($this->getRequest()->getPost());

            if ($form->isValid()) {
                $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
                $entity = $this->getEntity();
                $hydrator = new DoctrineHydrator($objectManager);
                $hydrator->hydrate($form->getData(), $entity);
                $objectManager->persist($entity);
                $objectManager->flush();
                $controller = explode('/', $this->getRequest()->getUri()->getPath())[2];
                if (!$this->getRequest()->isXmlHttpRequest()) {
                    return $this->redirect()->toRoute(null, ['controller' => $controller]);
                }
                return;
            } else {
                $this->getResponse()->setStatusCode(400);
            }
        }
        $viewModel = $this->getViewModel();
        $viewModel->setTerminal($this->getRequest()->isXmlHttpRequest());

        return $viewModel->setVariables(['form' => $form]);
    }
697394
public function create()
    {
        // Keep default options in an array and merge with incoming options that can override the defaults.
        $default = array(
            'id'          => null,
            'class'       => null,
            'wrapper'     => 'nav',
            'create_url'  => function ($url) {
                return $url;
            },
        );
        $menu = array_replace_recursive($default, $this->config);

        // Create the ul li menu from the array, use an anonomous recursive function that returns an
        // array of values.
        $createMenu = function ($items, $callback) use (&$createMenu, $menu) {
            
            $html = null;
            $hasItemIsSelected = false;

            foreach ($items as $item) {

                // has submenu, call recursivly and keep track on if the submenu has a selected item in it.
                $submenu        = null;
                $selectedParent = null;
            
                if (isset($item['submenu'])) {
                    list($submenu, $selectedParent) = $createMenu($item['submenu']['items'], $callback);
                    $selectedParent = $selectedParent
                        ? "selected-parent "
                        : null;
                }

                // Check if the current menuitem is selected
                $selected = $callback($item['url'])
                    ? "selected "
                    : null;
                
                // Check if the menuitem is a parent of current page, /controller for /controller/action
                $isParent = null;
                if (isset($item['mark-if-parent-of']) && $item['mark-if-parent-of'] == true) {
                    $isParent = $menu['is_parent']($item['mark-if-parent-of'])
                        ? "is-parent "
                        : null;
                }
                
                // Is there a class set for this item, then use it
                $class = isset($item['class']) && ! is_null($item['class'])
                    ? $item['class']
                    : null;

                // Prepare the class-attribute, if used
                $class = ($selected || $selectedParent || $isParent || $class)
                    ? " class='{$selected}{$selectedParent}{$isParent}{$class}' "
                    : null;

                // Add the menu item
                $url = $menu['create_url']($item['url']);
                $html .= "\n<li{$class}><a href='{$url}' title='{$item['title']}'>{$item['text']}</a>{$submenu}</li>\n";
                
                // To remember there is selected children when going up the menu hierarchy
                if ($selected) {
                    $hasItemIsSelected = true;
                }
            }

            // Return the menu
            return array("\n<ul>$html</ul>\n", $hasItemIsSelected);
        };

        // Call the anonomous function to create the menu, and submenues if any.
        list($html) = $createMenu($menu['items'], $menu['callback']);


        // Set the id & class element, only if it exists in the menu-array
        $id      = isset($menu['id'])    ? " id='{$menu['id']}'"       : null;
        $class   = isset($menu['class']) ? " class='{$menu['class']}'" : null;
        $wrapper = $menu['wrapper'];

        return "\n<{$wrapper}{$id}{$class}>{$html}</{$wrapper}>\n";
    }
726637
public function newAction()
    {
        $model = $this->loadModel();
        if (!$model->isObjectNew()) {
            $this->_forward('noroute');
            return;
        }

        if ($this->getRequest()->isPost()) {
            $postData = $this->getRequest()->getPost();
            try {
                $model->isObjectNew(true);
                foreach ($this->preprocessPostData($postData) as $key => $value) {
                    $model->setDataUsingMethod($key, $value);
                }
                $model->save();
                $this->_redirectUrl($this->getHelper()->getGridUrl());
                $this->_getSession()->addSuccess('Saved Successfully');
                return;
            } catch (Exception $e) {
                $message = $e->getMessage();
                if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) {
                    /** @var PDOException $e */
                    $e = $e->getChainedException();
                    if (isset($e->errorInfo[0]) && $e->errorInfo[0] == 23000 && isset($e->errorInfo[1]) && $e->errorInfo[1] == 1062) {
                        $message = $this->getHelper()->__(
                            "Record already exists for %s '%s'",
                            $model->getIdFieldName(),
                            $model->getId()
                        );
                    }
                }
                Mage::logException($e);
                $this->_getSession()->addError($message);
            }
        }

        $this->loadLayout();
        $this->renderLayout();
    }
321972
public function newAction()
    {
        $scope = new Scope();
        $form   = $this->createCreateForm($scope);

        return $this->render('ChillMainBundle:Scope:new.html.twig', array(
            'entity' => $scope,
            'form'   => $form->createView(),
        ));
    }
193915
public function __new($navigation = array())
    {
        // Create new entity
        $entity = new Material();
        $entity->Active = 1;
        $entity->Created = date('Y-m-d H:m:s');

        // Set user
        $user = $this->system->module('social')->user();

        if (isset($user->user_id)) {
            $entity->UserID = $user->userId;
        }
        else {
            $entity->UserID = '1';
        }

        // Persist
        $entity->save();

        // Set name for created material
        $entity->Name = t($this->name, true).' №'.$entity->id;
        $entity->Url = utf8_translit($entity->Name);

        // Check unique url for material
        if ($this->query->entity(Material::class)->where(Material::F_IDENTIFIER, utf8_translit($entity->Name))->first()) {
            $entity->Url = md5(utf8_translit($entity->Name));
        }

        // Persist
        $entity->save();

        Event::fire('samsoncms.app.material.new', array(&$entity));

        $navigation = is_array($navigation) ? $navigation : array($navigation);

        // Set navigation relation
        foreach (array_merge($navigation, static::$structures) as $structureID) {
            // Create relation with structure
            $structureMaterial = new NavigationMaterial();
            $structureMaterial->MaterialID = $entity->id;
            $structureMaterial->StructureID = $structureID;
            $structureMaterial->Active = '1';
            $structureMaterial->save();
        }

        // Go to correct form URL
        url()->redirect($this->system->module('cms')->baseUrl . '/' . $this->id . '/form/' . $entity->id);
    }
73059
public function create()
    {
        $header = '菜单管理';
        $description = '创建';
        return view('admin::system.menu-create', [
            'options' => Menu::selectOptions(),
            'permissions' => Permission::all(),
            'header' => $header,
            'description' => $description
        ]);
    }
854333
public function form()
    {
        return Menu::form(function (Form $form) {
            $form->display('id', 'ID');

            $form->select('parent_id', trans('merchant.parent_id'))->options(Menu::selectOptions());
            $form->text('title', trans('merchant.title'))->rules('required');
            $form->icon('icon', trans('merchant.icon'))->default('fa-bars')->rules('required')->help($this->iconHelp());
            $form->text('uri', trans('merchant.uri'));
            $form->multipleSelect('roles', trans('merchant.roles'))->options(Role::all()->pluck('name', 'id'));

            $form->display('created_at', trans('merchant.created_at'));
            $form->display('updated_at', trans('merchant.updated_at'));
        });
    }
419140
public function newAction()
    {
        $entity = new Collection();
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
102551
public function createAction()
    {
        $success    = null;
        $params     = $this->params();
        $request    = $this->getRequest();
        $type       = $params->fromRoute( 'type' );
        $parent     = $params->fromRoute( 'parentId', null );
        $menu       = $this->getModel()
                           ->create( array(
                                'type' => $type,
                            ) );

        $form = $this->getForm( $menu );

        if ( $request->isPost() )
        {
            $form->setData( $request->getPost() );

            if ( $form->isValid() && $menu->save() &&
                 ( empty( $parent ) || $this->getModel()
                                            ->appendTo( $menu->id, $parent ) ) )
            {
                $success = true;

                $this->messenger()
                     ->add( 'menu.form.success',
                            'menu', Message::LEVEL_INFO );
            }
            else
            {
                $success = false;

                $this->messenger()
                     ->add( 'menu.form.failed',
                            'menu', Message::LEVEL_ERROR );
            }
        }

        return array(
            'success'   => $success,
            'form'      => $form,
            'menu'      => $menu,
        );
    }
1082865
public function newAction()
        {

            $oRemoteApp = new RemoteApp();
            $oRemoteApp->setApiUrl("swControl/");
            $oRemoteApp->setActivated(true);
            $oRemoteApp->setIncludelog(true);
            $oRemoteApp->setNotificationRecipient($this->getUser()->getEmail());
            $oRemoteApp->setNotificationSender($this->getUser()->getEmail());
            $oRemoteApp->setNotificationChange(true);
            $oRemoteApp->setNotificationError(true);
            $form = $this->createCreateForm($oRemoteApp);

            return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
                'entity' => $oRemoteApp,
                'form'   => $form->createView(),
            ));
        }
136876
public function newAction()
        {

            $oCustomer = new Customer();
            $form      = $this->createCreateForm($oCustomer);

            return $this->render('SlashworksAppBundle:Customer:new.html.twig', array(
                'entity' => $oCustomer,
                'form'   => $form->createView(),
            ));
        }
519392
public function create()
  {
    if ( \Auth::user()->roles[0]->can('menu-create' ) ) {
      $items = $this->menus->pluck('name', 'id')->toarray();
      $roles = Role::pluck('name', 'id')->toarray();
      $selected = [];
      return \View::make('acl::admin.menus.create', [
        'items'    =>  $items,
        'roles'    =>  $roles,
        'selected' =>  $selected,
        'title'    => 'create',
      ]);
    }
    return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
  }