Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 /**
  * @return \Nette\Application\UI\Form
  */
 protected function createForm()
 {
     $form = new Form();
     $base = $form->addContainer('base');
     $password = $form->addContainer('password');
     $elections = $form->addContainer('elections');
     $base->addText('username', 'Uživatelské jméno')->addRule(Form::FILLED, "Vyplňte prosím uživatelské jméno");
     $base->addTextNull('name', 'Jméno')->addRule(Form::FILLED, "Vyplňte prosím jméno");
     $base->addTextNull('surname', 'Příjmení')->addRule(Form::FILLED, "Vyplňte prosím příjmení");
     $base->addText('email', 'Email')->setRequired()->addRule(Form::EMAIL, "Zadejte prosím validní emailovou adresu.");
     $password->addTextNull('password', 'Heslo')->setType('password')->setAttribute('autocomplete', 'off')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Zadané heslo je příliš krátké, zvolte si heslo alespoň o %d znacích', 8);
     $password->addPassword('passwordCheck', 'Heslo pro kontrolu')->setOmitted()->setAttribute('autocomplete', 'off')->addConditionOn($password['password'], Form::FILLED)->addRule(Form::EQUAL, 'Heslo pro kontrolu se neshoduje', $password['password']);
     $elections['role'] = $this->roleFormItemFactory->create();
     $elections['role']->addRule(Form::FILLED, "Přiřaďte prosím uživateli roli");
     $elections['section'] = $this->sectionFormItemFactory->createMultiselectBox();
     $form->addSubmit('save', 'Uložit');
     $form->onValidate[] = function (Form $form) {
         $this->checkUsername($form);
     };
     $form->onValidate[] = function (Form $form) {
         $this->checkNewUserPassword($form);
     };
     $form->onValidate[] = function (Form $form) {
         $this->checkSectionBindins($form);
     };
     return $form;
 }
Esempio n. 3
0
 protected function createForm()
 {
     $form = new Form();
     if ($this->isFrontSection()) {
         $form->addContainer('section')['section'] = $this->sectionFormItemFactory->createMultiselectBox();
     }
     $base = $form->addContainer('base');
     $base->addTextNull('name', 'Název');
     $base->addCheckbox('show', 'Zobrazit')->setDefaultValue(TRUE);
     $base->addTextAreaNull('content', 'Obsah stránky')->setAttribute('class', 'mceEditorSimple');
     $form->addSubmit('save', 'Uložit');
     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;
 }
Esempio n. 5
0
 /**
  * Add definition for builder
  *
  * @param array $definition
  * @return $this
  * @throws InvalidStateException
  */
 public function add($definition = array())
 {
     if (!isset($definition['propertyName'])) {
         throw new InvalidStateException("Missing property name!");
     }
     $propertyName = $definition['propertyName'];
     // load default rules
     $builderDefinition = $this->getPropertyRule($propertyName, !(isset($definition['componentType']) && $definition['componentType'] === BuilderDefinition::COMPONENT_TYPE_CONTAINER));
     if (isset($definition['componentType'])) {
         if ($definition['componentType'] === BuilderDefinition::COMPONENT_TYPE_CONTAINER) {
             $container = $this->form->addContainer($propertyName);
             $targetEntity = $this->invokeGetter($propertyName, $this->entity);
             if ($targetEntity === NULL) {
                 $className = $builderDefinition->getTargetEntity();
                 $targetEntity = new $className();
             }
             $isSpecified = isset($definition['settings']) && is_array($definition['settings']) && is_array($definition['settings'][0]);
             /** @var FormBuilder $builder */
             $builder = new self($this->entityFormMapper, $targetEntity, $this->entityManager, $this->dateParser, !$isSpecified, $container);
             if ($isSpecified) {
                 $builder->addAll($definition['settings']);
             }
             // try to map value
             $this->entityFormMapper->mapValueToComponent($targetEntity, $container);
             // end scope
             return $this;
         } else {
             $builderDefinition->setComponentType($definition['componentType']);
         }
     }
     if (isset($definition['settings'])) {
         $settings = $definition['settings'];
         if (isset($settings['required'])) {
             $builderDefinition->setRequired($settings['required']);
         }
         if (isset($settings['placeholder'])) {
             $builderDefinition->setPlaceholder($settings['placeholder']);
         }
         if (isset($settings['validationRules'])) {
             $builderDefinition->setValidationRules($settings['validationRules']);
         }
         if (isset($settings['label'])) {
             $builderDefinition->setLabel($settings['label']);
         }
         if (isset($settings['values']) && is_array($settings['values'])) {
             $builderDefinition->setValues($settings['values']);
         }
         if (isset($settings['value'])) {
             $builderDefinition->setValue($settings['value']);
         }
         if (isset($settings['appendValidationRules']) && is_array($settings['appendValidationRules'])) {
             foreach ($settings['appendValidationRules'] as $row) {
                 $builderDefinition->addValidationRuleRow($row);
             }
         }
     }
     // replace old
     $this->replaceFormControl($builderDefinition);
     return $this;
 }
Esempio n. 6
0
 /**
  * @return Form
  */
 protected function createForm()
 {
     $form = new Form();
     $form->addGroup('Základní údaje');
     $basic = $form->addContainer('basic');
     $basic->addText('name', 'Name');
     $form->addSubmit('save', 'Uložit');
     return $form;
 }
Esempio n. 7
0
 private function editPrivileges(Form $form, $permissions)
 {
     $priv = $form->addContainer('privileges');
     $priv->addCheckboxList('FastNews', 'Rychlé zprávy:', ['add' => 'Přidat', 'moderate' => 'Upravovat, mazat všem']);
     $priv->addCheckboxList('NewActions', 'Nové akce: ', ['add' => 'Přidat', 'moderate' => 'Upravovat, mazat všem']);
     $priv->addCheckboxList('Article', 'Články: ', ['add' => 'Napsat', 'publish' => 'Publikovat', 'moderate' => 'Upravovat, mazat všem']);
     $priv->addCheckboxList('Comments', 'Komentáře: ', ['addAsAdmin' => 'Přidávat jako admin', 'moderate' => 'Upravovat, mazat']);
     $priv->addCheckboxList('User', 'Uživatele: ', ['add' => 'Přidávat neregistrované', 'see' => 'Zobrazit seznam', 'prohibit' => 'Udělit BAN', 'moderate' => 'Upravovat, mazat']);
     $priv->addCheckboxList('ArtTeam', 'Art team: ', ['see' => 'Zobrazit kontaky na členy', 'add' => 'Přidávat členy', 'moderate' => 'Upravovat, mazat jakékoliv členy']);
     $priv->addCheckboxList('MediaArchive', 'Media archiv: ', ['see' => 'Zobrazit media', 'add' => 'Přidávat do media archivu', 'moderate' => 'Upravovat, mazat jakýkoliv obsah']);
     $priv->addCheckboxList('Section', 'Skece k článkům:', ['moderate' => 'upravovat']);
     $priv->setDefaults($this->parseRole($permissions));
 }
 protected function createComponentRole()
 {
     $form = new Form();
     $form->addHidden("id");
     $cont = $form->addContainer("role");
     $role = $this->uzivatele->getRolePairs();
     foreach ($role as $k => $v) {
         $cont->addCheckbox($k, $v);
     }
     $form->addSubmit("save", "Uložit");
     $form->onSuccess[] = $this->saveRole;
     return $form;
 }
Esempio n. 9
0
 /**
  * Adds select box to filter form
  * @param Nette\Application\UI\Form $form
  */
 public function addToFormContainer($form)
 {
     $container = $form->addContainer($this->key);
     $container->addText('from', $this->name);
     $container->addText('to', $this->name_second);
     if ($placeholder = $this->getPlaceholder()) {
         if ($text_from = reset($placeholder)) {
             $form[$this->key]['from']->setAttribute('placeholder', $text_from);
         }
         if ($text_to = end($placeholder) && $text_to != $text_from) {
             $form[$this->key]['to']->setAttribute('placeholder', $text_to);
         }
     }
 }
Esempio n. 10
0
 /**
  * Adds select box to filter form
  * @param Nette\Application\UI\Form $form
  */
 public function addToFormContainer($form)
 {
     $container = $form->addContainer($this->key);
     $container->addText('from', $this->name)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true');
     $container->addText('to', $this->name_second)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true');
     if ($placeholder = $this->getPlaceholder()) {
         if ($text_from = reset($placeholder)) {
             $form[$this->key]['from']->setAttribute('placeholder', $text_from);
         }
         if ($text_to = end($placeholder) && $text_to != $text_from) {
             $form[$this->key]['to']->setAttribute('placeholder', $text_to);
         }
     }
 }
Esempio n. 11
0
 /**
  * @param string[] $websites
  * @param \App\Holder\PageRelated[] $duels
  * @return Form
  */
 public function create($websites, $duels)
 {
     $periods = array(RespondentWebsite::PERIOD_KNOW_AND_VISIT => "Znám a navštěvuji", RespondentWebsite::PERIOD_KNOW_THAT_EXISTS => "Pouze vím, že existuje", RespondentWebsite::PERIOD_DONT_KNOW => "Neznám");
     $form = new Form($this->parent, "finalForm");
     $form->addGroup("Znáte následující stránky?");
     $websites_container = $form->addContainer("website");
     foreach ($websites as $website_id => $website_name) {
         $website_container = $websites_container->addContainer($website_id);
         $website_container->addRadioList("period", $website_name, $periods)->setAttribute("class", "buttons-group");
     }
     $form->addGroup("Jaké stránky navštěvujete častěji?");
     $duels_container = $form->addContainer("duels");
     foreach ($duels as $page_related_holder) {
         $duel_container = $duels_container->addContainer($page_related_holder->getPageRelated()->id_page_related);
         $title = $page_related_holder->getPageA()->getWebsite()->name . " vs. " . $page_related_holder->getPageB()->getWebsite()->name;
         $options = array($page_related_holder->getPageA()->getPage()->id_page => $page_related_holder->getPageA()->getWebsite()->name, RespondentPageDuel::MORE_OFTEN_BOTH => "nastejno", $page_related_holder->getPageB()->getPage()->id_page => $page_related_holder->getPageB()->getWebsite()->name, RespondentPageDuel::MORE_OFTEN_NONE => "nenavštěvuji ani jeden web");
         $duel_container->addRadioList("page", $title, $options)->setAttribute("class", "buttons-group");
     }
     $form->addGroup(null);
     $form->addText("email", "E-mail")->setType("email");
     $form->addSubmit("send", "Dokončit dotazník")->setAttribute("class", "btn btn-lg btn-primary");
     return $form;
 }
Esempio n. 12
0
 public function vytvorit()
 {
     $form = new Form();
     $umiestnenie = $form->addContainer('umiestnenie');
     $umiestnenie->addText('nazov', '*Názov:')->setRequired();
     $umiestnenie->addText('sirka', 'Šírka:')->addCondition(Form::FILLED)->addRule(Form::FLOAT, 'Pole musi obsahovať iba čísla!');
     $umiestnenie->addText('dlzka', 'Dĺžka:')->addCondition(Form::FILLED)->addRule(Form::FLOAT, 'Pole musi obsahovať iba čísla!');
     $umiestnenie->addText('vyska', 'Výška:')->addCondition(Form::FILLED)->addRule(Form::FLOAT, 'Pole musi obsahovať iba čísla!');
     if ($this->mod == 0) {
         $klietka = $form->addContainer('klietka');
         $klietka->addText('typ', 'Typ:');
         $klietka->addText('podstielka', 'Podstielka:');
         $klietka->addText('lokacia', 'Lokácia:');
     } else {
         $vybeh = $form->addContainer('vybeh');
         $vybeh->addText('teren', 'Terén:');
         $vybeh->addText('povrch', 'Povrch:');
         $vybeh->addText('ohradenie', 'Ohradenie:');
     }
     $form->addSubmit('vytvorit', 'Vytvoriť');
     $form->onSuccess[] = array($this, 'uspesne');
     $form->setRenderer(new Bs3FormRenderer());
     return $form;
 }
 /**
  * @param string $name
  */
 public function createComponentEditUserCollectionForm($name)
 {
     $form = new Form($this, $name);
     $albumsContainer = $form->addContainer('albums');
     $albums = $this->albumModel->getAll();
     /**
      * @var Album $album
      */
     foreach ($albums as $album) {
         $label = $album->getAlbumName() . '(' . $album->getArtist() . ', ' . $album->getYear() . ')';
         $albumsContainer->addCheckbox($album->getAlbumId(), $label);
     }
     foreach ($this->user->getAlbums() as $userAlbums) {
         $albumsContainer[$userAlbums->getAlbumId()]->setDefaultValue(TRUE);
     }
     $form->addSubmit('assign', 'Assign');
     $form->onSuccess[] = $this->successEditUserCollectionForm;
 }
 public function create()
 {
     $form = new Form();
     $rows = $form->addContainer("rows");
     foreach ($this->targetList as $target) {
         $container = $rows->addContainer($target->id);
         $container->addText("seoTitle");
         $container->addTextArea("seoKeywords");
         $container->addTextArea("seoDescription");
         $container->addSelect("seoRobots", NULL, array("index" => "index", "noindex" => "noindex"));
         $container->addSelect("sitemapChangeFreq", NULL, array("always" => "always", "hourly" => "hourly", "daily" => "daily", "weekly" => "weekly", "monthly" => "monthly", "yearly" => "yearly", "never" => "never"));
         $container->addText("sitemapPriority", NULL)->setType("number")->setAttribute("step", "0.1")->addRule(Form::FLOAT, "Priority must be number between 0 and 1")->addRule(Form::RANGE, "Priority must be number between 0 and 1", array(0, 1));
         $container->addSubmit("save", "Save")->setValidationScope($container->getComponents())->onClick[] = $this->processSingleRow;
         $meta = $target->meta;
         $container->setDefaults(array("seoTitle" => $meta->seoTitle, "seoKeywords" => $meta->seoKeywords, "seoDescription" => $meta->seoDescription, "seoRobots" => $meta->seoRobots, "sitemapChangeFreq" => $meta->sitemapChangeFreq, "sitemapPriority" => $meta->sitemapPriority));
     }
     $form->addSubmit("send", "Save all")->onClick[] = $this->processEntireForm;
     return $form;
 }
 /**
  * @param Category[] $categories
  * @param string|null $code
  * @return Form
  */
 public function create($categories, $code = null)
 {
     $validaton_message = "Vyplňte prosím %s. Pomůže mi to lépe zpracovat výsledky průzkumu. Díky ;)";
     $form = new Form($this->parent, $this->name);
     $form->addGroup("Obecné");
     $sex = array(Respondent::GENDER_MALE => 'muž', Respondent::GENDER_FEMALE => 'žena');
     $form->addRadioList('gender', 'Pohlaví:', $sex)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "svoje pohlaví");
     $age = array(Respondent::AGE_15 => 'méne něž 15', Respondent::AGE_15_20 => '15-20', Respondent::AGE_21_30 => '21-30', Respondent::AGE_31_45 => '31-45', Respondent::AGE_46_60 => '46-60', Respondent::AGE_60 => 'více než 60');
     $form->addRadioList('age', 'Věk', $age)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "svůk věk");
     $truefalseoptions = array(1 => "Ano", 0 => "Ne");
     $form->addRadioList("english", "Navštěvuji anglické webové stránky", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda navštěvujete i anglické webové stránky");
     $form->addRadioList("it", "Pracuji v oboru IT nebo tento obor studuji", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda pracujete v oboru IT nebo ho studujete");
     if ($code !== null) {
         $form->addHidden("code", $code);
     }
     $form->addTextArea("sites", "Jaké stránky často navštěvuji");
     $devices = array(Respondent::DEVICE_COMPUTER => "Počítač nebo notebook", Respondent::DEVICE_PHONE => "Smartphone", Respondent::DEVICE_TABLET => "Tablet");
     $form->addCheckboxList('device', 'K přístupu na internet používám:', $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení používáte pro přístup k internetu");
     $form->addRadioList("device_most", "A z toho nejčastěji", $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení nejčastěji používáte pro přístup k internetu");
     $period = array(EntityCategory::PERIOD_NEVER => "vůbec", EntityCategory::PERIOD_DAILY => "denně", EntityCategory::PERIOD_FEW_TIMES_A_WEEK => "několikrát týdně", EntityCategory::PERIOD_FEW_TIMES_A_MONTH => "několikrát měsíčně", EntityCategory::PERIOD_FEW_TIMES_A_YEAR => "několikrát ročně");
     $categories_container = $form->addContainer("category");
     foreach ($categories as $holder_category) {
         $category_container = $categories_container->addContainer($holder_category->getCategory()->id_category);
         $category_container->setCurrentGroup($categories_container->getForm()->addGroup($holder_category->getCategory()->label));
         $category_container->addRadioList("period", "Jak často?", $period)->setAttribute("class", "buttons-group");
         if ($holder_category->getChildren()) {
             $items = array();
             foreach ($holder_category->getChildren() as $child) {
                 $items[$child->id_category] = $child->label;
             }
             $category_container->addCheckboxList("items", $holder_category->getCategory()->child_label, $items)->setAttribute("class", "buttons-group");
         }
     }
     $form->setCurrentGroup(NULL);
     $form->addGroup("Zajímá mě to");
     $form->addText("nickname", "Nick (chci být v highscore)");
     $form->addText("email", "E-mail")->setType("email");
     $form->addTextArea("message", "Vzkaz");
     $form->addSubmit("validate", "Pokračovat")->setAttribute("class", "btn btn-primary");
     $form->addSubmit("nonvalidate", "Přejít rovnou k otázkám")->setValidationScope(FALSE)->setAttribute("class", "btn btn-default");
     return $form;
 }
Esempio n. 16
0
 public function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('like');
     $like->addText('name', 'Name:');
     $like->addText('zip', 'Zip:');
     $created = $form->addContainer('simple');
     $created->addSelect('shire_id', 'Shire:', $this->system->getShiresToSelect())->controlPrototype->onChange("submit();");
     $form->addSubmit('set', 'Set');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form['reset']->getControlPrototype()->class('cancel');
     $form->onSuccess[] = array($this, 'setFilter');
     return $form;
 }
Esempio n. 17
0
 protected function createComponentGridForm()
 {
     $form = new \Nette\Application\UI\Form();
     $form->method = "POST";
     $form->getElementPrototype()->class[] = "grid-gridForm";
     $form->addContainer($this->name);
     $form[$this->name]->addContainer("rowForm");
     $form[$this->name]['rowForm']->addSubmit("send", "Save");
     $form[$this->name]['rowForm']['send']->getControlPrototype()->addClass("grid-editable");
     $form[$this->name]->addContainer("filter");
     $form[$this->name]['filter']->addSubmit("send", "Filter")->setValidationScope(FALSE)->getControlPrototype()->class('btn btn-primary');
     $form[$this->name]->addContainer("action");
     $form[$this->name]['action']->addSelect("action_name", "Selected:");
     $form[$this->name]['action']->addSubmit("send", "Confirm")->setValidationScope(FALSE)->getControlPrototype()->addData("select", $form[$this->name]["action"]["action_name"]->getControl()->name);
     $form[$this->name]->addContainer('perPage');
     $form[$this->name]['perPage']->addSelect("perPage", "Items on page:", $this->perPageValues)->getControlPrototype()->addClass("grid-changeperpage")->addData("gridname", $this->getGridPath())->addData("link", $this->link("changePerPage!"));
     $form[$this->name]['perPage']->addSubmit("send", "OK")->setValidationScope(FALSE)->getControlPrototype()->addClass("grid-perpagesubmit");
     $form->setTranslator($this->getTranslator());
     $form->onSuccess[] = callback($this, "processGridForm");
     return $form;
 }
Esempio n. 18
0
 public function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('like');
     $like->addText('name', 'Název:');
     $like->addSelect('mimetype', 'Typ:', array(0 => '---', 'image' => 'Images', 'text' => 'Text', 'word' => 'Word', 'excel' => 'Excel', 'pdf' => 'PDF'))->controlPrototype->onChange("submit();");
     $created = $form->addContainer('created');
     $created->addSelect('day', 'Datum:', $this->items->getDaysToSelect())->controlPrototype->onChange("submit();");
     $created->addSelect('month', '', $this->items->getMonthsToSelect())->controlPrototype->onChange("submit();");
     $created->addSelect('year', '', $this->items->getYearsToSelect())->controlPrototype->onChange("submit();");
     $like = $form->addContainer('boolean');
     $like->addSelect('visible', 'Visibility:', array(0 => '---', 'false' => 'Hidden', 'true' => 'Visible'))->controlPrototype->onChange("submit();");
     $form->addSubmit('set', 'Set');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form->onSuccess[] = array($this, 'setFilter');
     return $form;
 }
Esempio n. 19
0
 protected function createComponentFormTranslate()
 {
     $presenter = $this;
     return new Multiplier(function ($id, $control) use($presenter) {
         $message = $presenter->messageFacade->find($id);
         $form = new Form();
         $form->addHidden('id', $id);
         $form->addHidden('plural', $message->hasPlural());
         $translations = $form->addContainer('translations');
         for ($i = 0; $i < $message->getPluralsCount(); $i++) {
             if ($i === 0) {
                 $translations->addTextArea(sprintf('%d', $i), 'Singular');
             } else {
                 $translations->addTextArea(sprintf('%d', $i), sprintf('Plural form %d', $i));
             }
         }
         $form->addSubmit('btnSubmit', 'Save');
         $form->setDefaults(array('translations' => $message->getTranslations()));
         $form->onSuccess[] = callback($presenter, 'formTranslateSubmitted');
         return $form;
     });
 }
Esempio n. 20
0
 /** Vytvoření formuláře
  * 
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->id = "resourceForm";
     $form->addText("name", "Jméno modulu:")->setHtmlId("name")->setRequired("Prosím zadejte jméno modulu.");
     $form->addHidden("aclResourceID");
     $form->addButton("cancel", "Storno")->setHtmlId("cancel");
     $form->addSubmit("sender", "Uložit změny")->setHtmlId("sender");
     $actions = $this->actionRepository->read();
     $container = $form->addContainer("actions");
     foreach ($actions as $key => $action) {
         $container->addCheckbox($key, $action->humanName);
     }
     if ($this->aclResourceID) {
         $modelEntities = $this->modelRepository->read()->where("aclResourceID", $this->aclResourceID);
         $modelEntity = $modelEntities->fetch();
         if ($modelEntity) {
             $form['aclResourceID']->setValue($modelEntity->getAclResource()->getAclResourceID());
             $form['name']->setValue($modelEntity->getAclResource()->name);
             foreach ($modelEntities as $entity) {
                 $form["actions"][$entity->aclActionID]->setValue(TRUE);
             }
         } else {
             $resourceEntity = $this->resourceRepository->get($this->aclResourceID);
             if ($resourceEntity) {
                 $form['aclResourceID']->setValue($this->aclResourceID);
                 $form['name']->setValue($resourceEntity->getName());
             }
         }
     }
     $form->onSuccess[] = callback($this, "Submit");
     $form->onError[] = callback($this, "Error");
     return $form;
 }
Esempio n. 21
0
 protected function createComponentForm()
 {
     $form = new Form();
     $filterContainer = $form->addContainer('filter');
     foreach ($this->filterFormCallback as $callback) {
         Callback::invokeArgs($callback, [$filterContainer]);
     }
     $filterContainer->addSelect('limit', 'Limit', [10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 100 => 100, 200 => 200, 300 => 300, 400 => 400, 500 => 500]);
     $filterContainer->addText('fulltext', 'Fulltext');
     $filterContainer->addSubmit('submit', 'Search');
     $batch = $form->addContainer('batchSubmit');
     foreach ($this->batchActions as $batchAction) {
         $batch->addSubmit($batchAction->name, $batchAction->label)->onClick[] = function (SubmitButton $submitButton) use($batchAction) {
             Callback::invokeArgs($batchAction->callback, [$submitButton->getParent()->getParent()->getHttpData(Form::DATA_TEXT, 'batch[]')]);
             $this->redirect('this');
         };
     }
     $form->onSuccess[] = [$this, 'formSucceed'];
     return $form;
 }
Esempio n. 22
0
 /**
  * FilterAndGroupAction form factory
  * @return Form
  */
 public function createComponentFilter()
 {
     $form = new Form($this, 'filter');
     $form->setMethod('get');
     /**
      * Filter part
      */
     $filter_container = $form->addContainer('filter');
     foreach ($this->filters as $filter) {
         $filter->addToFormContainer($filter_container, $filter_container);
     }
     /**
      * Group action part
      */
     $group_action_container = $form->addContainer('group_action');
     if ($this->hasGroupActions()) {
         $this->getGroupActionCollection()->addToFormContainer($group_action_container, $form, $this->getTranslator());
     }
     $form->setDefaults(['filter' => $this->filter]);
     $form->onSubmit[] = [$this, 'filterSucceeded'];
     return $form;
 }
Esempio n. 23
0
 /**
  * TakeTest form form factory.
  * @return Nette\Application\UI\Form
  */
 protected function createComponentTakeTestForm()
 {
     $form = new Nette\Application\UI\Form();
     $testId = $this->params['id'];
     $questions = $this->questions->getQuestionsInTest($testId);
     $form->addGroup('questions');
     foreach ($questions as $key => $question) {
         $questionsGroup = $form->addContainer('group' . $key);
         $type = $question->type;
         $questionsGroup->addHidden('question_id_' . $key)->setDefaultValue($question->id);
         //Výběr jedné správné odpověďi
         if ($type == 'radio') {
             //Answers
             $answers = array('a' => $question->answer_a, 'b' => $question->answer_b);
             if (!empty($question->answer_c)) {
                 $answers['c'] = $question->answer_c;
             }
             if (!empty($question->answer_d)) {
                 $answers['d'] = $question->answer_d;
             }
             //Answer radio list
             $questionsGroup->addRadioList('answer' . $key, $question->question, $answers)->setAttribute('data-question_id', $question->id)->setRequired('Vyber odpověď k otázce: ' . $question->question);
         }
         //Výběr více odpověďí
         if ($type == 'checkbox') {
             //Answers
             $answers = array('a' => $question->answer_a, 'b' => $question->answer_b);
             if (!empty($question->answer_c)) {
                 $answers['c'] = $question->answer_c;
             }
             if (!empty($question->answer_d)) {
                 $answers['d'] = $question->answer_d;
             }
             //Answer radio list
             $questionsGroup->addCheckboxList('answer' . $key, $question->question, $answers)->setAttribute('data-question_id', $question->id)->setRequired('Vyber odpověďi k otázce: ' . $question->question);
         }
         //Textová odpověď
         if ($type == 'text') {
             $questionsGroup->addText('answer' . $key, $question->question)->setAttribute('data-question_id', $question->id)->setRequired('Vyplň odpověď k otázce: ' . $question->question);
         }
         // $questionsGroup->addHidden('answer_type'.$key)->setDefaultValue($type);
     }
     // $form->addHidden('test_id')->setDefaultValue($testId);
     $form->addGroup('submit');
     $form->addSubmit('submit', 'Odeslat test');
     $form->onSuccess[] = array($this, 'takeTestFormFormSucceeded');
     return $form;
 }
Esempio n. 24
0
 public function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('like');
     $like->addText('name', 'Name:');
     $like->addText('surname', 'Surname:');
     $like->addText('username', 'Username:'******'set', 'Set');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form->onSuccess[] = array($this, 'setFilter');
     $form->setTranslator($this->translator);
     return $form;
 }
Esempio n. 25
0
 /**
  * FilterAndGroupAction form factory
  * @return Form
  */
 public function createComponentFilter()
 {
     $form = new Form($this, 'filter');
     $form->setMethod(static::$form_method);
     $form->setTranslator($this->getTranslator());
     /**
      * InlineEdit part
      */
     $inline_edit_container = $form->addContainer('inline_edit');
     if ($this->inlineEdit instanceof InlineEdit) {
         $inline_edit_container->addSubmit('submit', 'ublaboo_datagrid.save');
         $inline_edit_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')->setValidationScope(FALSE);
         $this->inlineEdit->onControlAdd($inline_edit_container);
         $this->inlineEdit->onControlAfterAdd($inline_edit_container);
     }
     /**
      * InlineAdd part
      */
     $inline_add_container = $form->addContainer('inline_add');
     if ($this->inlineAdd instanceof InlineEdit) {
         $inline_add_container->addSubmit('submit', 'ublaboo_datagrid.save');
         $inline_add_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')->setValidationScope(FALSE)->setAttribute('data-datagrid-cancel-inline-add', TRUE);
         $this->inlineAdd->onControlAdd($inline_add_container);
         $this->inlineAdd->onControlAfterAdd($inline_add_container);
     }
     /**
      * ItemDetail form part
      */
     $items_detail_form = $this->getItemDetailForm();
     if ($items_detail_form instanceof Nette\Forms\Container) {
         $form['items_detail_form'] = $items_detail_form;
     }
     /**
      * Filter part
      */
     $filter_container = $form->addContainer('filter');
     foreach ($this->filters as $filter) {
         $filter->addToFormContainer($filter_container);
     }
     if (!$this->hasAutoSubmit()) {
         $filter_container['submit'] = $this->getFilterSubmitButton();
     }
     /**
      * Group action part
      */
     $group_action_container = $form->addContainer('group_action');
     if ($this->hasGroupActions()) {
         $this->getGroupActionCollection()->addToFormContainer($group_action_container);
     }
     if (!$form->isSubmitted()) {
         $this->setFilterContainerDefaults($form['filter'], $this->filter);
     }
     /**
      * Per page part
      */
     $form->addSelect('per_page', '', $this->getItemsPerPageList())->setTranslator(NULL);
     if (!$form->isSubmitted()) {
         $form['per_page']->setValue($this->getPerPage());
     }
     $form->addSubmit('per_page_submit', 'ublaboo_datagrid.per_page_submit');
     $form->onSubmit[] = [$this, 'filterSucceeded'];
 }
Esempio n. 26
0
 public function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('boolean');
     $like->addSelect('is_active', 'Activity:', array(0 => '---', 'true' => 'Active', 'false' => 'InActive'))->controlPrototype->onChange("submit();");
     $form->addSubmit('set', 'Set');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form->onSuccess[] = array($this, 'setFilter');
     return $form;
 }
Esempio n. 27
0
 protected function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('like');
     $like->addText('author', 'Author:');
     $like->addText('description', 'Description:');
     $like = $form->addContainer('boolean');
     $like->addSelect('visible', 'Visibility:', array(0 => '---', 'false' => 'Hidden', 'true' => 'Visible'))->controlPrototype->onChange("submit();");
     $form->addSubmit('set', 'Set')->getControlPrototype()->class('primary');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form['reset']->getControlPrototype()->class('cancel');
     $form->onSuccess[] = array($this, 'setFilter');
     return $form;
 }
Esempio n. 28
0
 public function createComponentFilterForm()
 {
     $form = new AppForm();
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'p';
     $renderer->wrappers['pair']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $like = $form->addContainer('like');
     $like->addText('name', 'Name:');
     $form->addSubmit('set', 'Set');
     $form->addSubmit('reset', 'Reset')->onClick[] = array($this, 'resetFilter');
     $form['reset']->getControlPrototype()->class('cancel');
     $form->onSuccess[] = array($this, 'setFilter');
     return $form;
 }
Esempio n. 29
0
 /**
  * FilterAndGroupAction form factory
  * @return Form
  */
 public function createComponentFilter()
 {
     $form = new Form($this, 'filter');
     $form->setMethod('get');
     $form->setTranslator($this->getTranslator());
     /**
      * InlineEdit part
      */
     $inline_edit_container = $form->addContainer('inline_edit');
     if ($this->inlineEdit instanceof InlineEdit) {
         $inline_edit_container->addSubmit('submit', 'ublaboo_datagrid.save');
         $inline_edit_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')->setValidationScope(FALSE);
         $this->inlineEdit->onControlAdd($inline_edit_container);
     }
     /**
      * InlineAdd part
      */
     $inline_add_container = $form->addContainer('inline_add');
     if ($this->inlineAdd instanceof InlineEdit) {
         $inline_add_container->addSubmit('submit', 'ublaboo_datagrid.save');
         $inline_add_container->addSubmit('cancel', 'ublaboo_datagrid.cancel')->setValidationScope(FALSE)->setAttribute('data-datagrid-cancel-inline-add', TRUE);
         $this->inlineAdd->onControlAdd($inline_add_container);
     }
     /**
      * ItemDetail form part
      */
     $items_detail_form = $this->getItemDetailForm();
     if ($items_detail_form instanceof Nette\Forms\Container) {
         $form['items_detail_form'] = $items_detail_form;
     }
     /**
      * Filter part
      */
     $filter_container = $form->addContainer('filter');
     foreach ($this->filters as $filter) {
         $filter->addToFormContainer($filter_container);
     }
     /**
      * Group action part
      */
     $group_action_container = $form->addContainer('group_action');
     if ($this->hasGroupActions()) {
         $this->getGroupActionCollection()->addToFormContainer($group_action_container);
     }
     $form->setDefaults(['filter' => $this->filter]);
     $form->onSubmit[] = [$this, 'filterSucceeded'];
     return $form;
 }
Esempio n. 30
0
 /**
  * @param  string  $name
  * @param  Form    $form
  * @return Section|NULL
  */
 private function createSection($name, Form $form)
 {
     $section = $this->addSection($name);
     $scheme = $this->getScheme();
     if (isset($scheme[$name])) {
         $section->setScheme($scheme[$name]);
     }
     $fields = $section->getComponents(FALSE, InputProvider::class);
     $page = $form->addContainer($section->getName());
     foreach ($fields as $field) {
         $field->createInput($page);
     }
     return $section;
 }