protected function createForm() { $form = new Form(); Container::extensionMethod('addLazyContainer', function ($container, $name, $factory) { return $container[$name] = new LazyContainer($factory); }); $base = $form->addContainer('base'); $base->addText('name', 'Název'); $type = $base->addSelect('type', 'Typ položky', $this->menuTypeOptionFactory->getOptionsBySection($this->sectionId)); $type->setDefaultValue(key($type->getItems())); $type->setAttribute('class', 'change-ajax-submit'); $base->addCheckbox('show', 'Zobrazit')->setDefaultValue(TRUE); $parent = $form->addContainer('parent'); $menu = $parent['id_menu'] = $this->menuFormItemFactory->create($this->sectionId); $menu->setPrompt('---'); $menu->caption = 'Rodičovská kategorie'; $form->addLazyContainer('content', function (LazyContainer $self) use($form, $type) { $values = $self->getFormValues(); $itemType = $values['base']['type']; $this->lazyItemMap->get($itemType)->setup($self, $this->sectionId); }); $form->addSubmit('save', 'Uložit'); $form->onValidate[] = $this->validateNonCircular; $form->onValidate[] = $this->validateAjax; $form->onValidate[] = $this->validateLazyItem; return $form; }
/** * @return \Nette\Application\UI\Form */ protected function createForm() { $form = new Form(); $base = $form->addContainer('base'); $type = $form->addContainer('type'); $base->addText('name', 'Název sekce'); $base->addText('domain', 'Doména třetího řádu'); $base->addText('priority', 'Priorita')->setDefaultValue(0); $base['module'] = $this->moduleFormItemFactory->create(); $type->addMultiSelect('menu_type_code', 'Povolené typy položek menu', $this->menuTypeOptionFactory->getOptions())->setAttribute('class', 'select2'); $form->addSubmit('save', 'Uložit'); return $form; }