public function configure(Form $form) { $group = $form->addGroup(); $form->addText('name', 'Name'); $form->addOne('route')->setCurrentGroup($group)->addTextArea('notation', 'Description', NULL, 4); $form->addSaveButton('Save'); }
/** * @param Form $form * @param $name * @return \DoctrineModule\Forms\Containers\EntityContainer */ public function addMailform($form, $name) { /** @var $container Form */ $container = $form->addOne($name); $container->setCurrentGroup($form->addGroup('Sender')); $container->addCheckbox('sendCopyToSender', 'Send copy to sender')->addCondition($form::EQUAL, true)->toggle('copyHeader')->toggle('copyRecipient'); $container->setCurrentGroup($group = $form->addGroup()); $group->setOption('id', 'copyHeader'); $container->addTextArea('copyHeader', 'Header of copy')->getControlPrototype()->attrs['class'] = 'input-block-level'; $container->setCurrentGroup($form->addGroup('Recipient')); $container->addTags('emails', 'E-mails')->addRule($form::FILLED, 'Please set e-mail.'); $container->setCurrentGroup($group = $form->addGroup()); $group->setOption('id', 'copyRecipient'); $container->addText('recipient', 'Recipient name')->addConditionOn($container['sendCopyToSender'], $form::EQUAL, true)->addRule($form::FILLED, 'Please set recipient name.'); $container->setCurrentGroup($group = $form->addGroup()); $container->addText('subject', 'Subject')->addRule($form::FILLED, 'Please set subject.'); $container->addCheckbox('ownTemplate', 'Advanced options')->addCondition($form::EQUAL, true)->toggle('template'); $container->setCurrentGroup($group = $form->addGroup()); $group->setOption('id', 'template'); $container->addTextarea('template', 'Mail template')->getControlPrototype()->attrs['class'] = 'input-block-level'; $container->setCurrentGroup($group = $form->addGroup('Inputs')); $mainContainer = $container; /** @var $items \Nette\Forms\Container */ $items = $container->addMany('inputs', function (\Nette\Forms\Container $container) use($group, $form, $mainContainer) { $container->setCurrentGroup($group); $container->addText('label', 'Label'); $container->addSelect('type', 'Type', InputEntity::getTypes())->addCondition($form::IS_IN, array(InputEntity::TYPE_CHECKBOX_LIST, InputEntity::TYPE_RADIO_LIST, InputEntity::TYPE_SELECT))->toggle("frm{$form->getUniqueId()}-{$mainContainer->getName()}-inputs-{$container->getName()}-items-pair")->endCondition()->addCondition($form::IS_IN, array(InputEntity::TYPE_CHECKBOX, InputEntity::TYPE_TEXT, InputEntity::TYPE_TEXTAREA, InputEntity::TYPE_CHECKBOX_LIST, InputEntity::TYPE_RADIO_LIST, InputEntity::TYPE_SELECT))->toggle("frm{$form->getUniqueId()}-{$mainContainer->getName()}-inputs-{$container->getName()}-required-pair"); $container->addTags('items', 'Items'); $container->addCheckbox('required', 'Required'); $container->addSubmit('remove', 'Remove input')->addRemoveOnClick(); }); $items->setCurrentGroup($group = $form->addGroup()); $items->addSubmit('add', 'Add input')->setValidationScope(FALSE)->addCreateOnClick(); }
public function configure(Form $form) { $_this = $this; $route = $form->addOne('route'); $group = $form->addGroup(); $route->setCurrentGroup($group); $form->addText('name', 'Name'); $form->addText('price', 'Price')->setDefaultValue(0)->addCondition($form::FILLED)->addRule($form::FLOAT); $form->addText('rrp', 'RRP')->addCondition($form::FILLED)->addRule($form::FLOAT); $route->addTextArea('notation', 'Description'); $route->addFileEntityInput('photo', 'Image'); $form->addText('inStock', 'In stock')->addCondition($form::FILLED)->addRule($form::FLOAT); $form->addGroup(''); $form->addManyToOne('category', 'Main category'); $form->addManyToMany('categories', 'Next categories'); $form->addGroup(); $form->addManyToMany('labels', 'Labels'); $tags = $form->addContainer('tags'); $tags->setCurrentGroup($group = $form->addGroup()); $form->addGroup('Types'); $form->addTags('typesAsArray', 'Types')->setSuggestCallback(function () use($_this, $form) { $ret = array(); foreach ($_this->getTagsFromCategories($form) as $tag) { $ret[$tag] = $tag; } return $ret; })->setDelimiter('[;]+')->setJoiner(';'); $form->addGroup(); $form->addSaveButton('Save'); }
public function configure(Form $form) { $group = $form->addGroup(); $form->addText('name', 'Name'); $form->addOne('route')->setCurrentGroup($group)->addTextArea('notation', 'Notation', NULL, 4)->getControlPrototype()->attrs['class'] = 'input-block-level'; $form->addSaveButton('Save'); }
public function configure(Form $form) { $group = $form->addGroup(); $form->addText('name', 'Name'); $form->addOne('route')->setCurrentGroup($group)->addTextArea('notation', 'Notation', NULL, 4)->getControlPrototype()->attrs['class'] = 'input-block-level'; $form->addManyToOne('linkedRoute', 'Linked route')->setCriteria(array('page' => $form->data->extendedPage->linkedPage->id)); $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $route = $form->addOne('conditions')->addOne('route'); $route->setCurrentGroup($form->addGroup()->setOption('class', 'full')); $route->addContentEditor('text', NULL, NULL, 30)->getControlPrototype()->class[] = 'input-block-level'; $route['text']->getControlPrototype()->data['cms-route'] = $form->data->page->mainRoute->id; $route['text']->getControlPrototype()->data['cms-page'] = $form->data->page->id; $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $page = $form->addOne('page'); $mainRoute = $page->addOne('mainRoute'); $mainRoute->setCurrentGroup($form->addGroup()); $mainRoute->addCheckbox('published', 'Publish'); $mainRoute->addDateTime('released', 'Release')->addRule($form::FILLED); $mainRoute->addDateTime('expired', 'Expire'); $form->setCurrentGroup(); $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $route = $form->addOne('route'); $group = $form->addGroup(); $form->addText('name', 'Name'); $route->setCurrentGroup($group); $route->addTextArea('notation', 'Notation'); $form->addManyToOne('parent', 'Parent'); $route->addFileEntityInput('photo', 'Photo'); $form->addGroup(); $form->addSaveButton('Save'); }
/** * @param Form $form */ protected function configure(Form $form) { $form->addGroup(); $user = $form->addOne('user'); $user->addMany('loginProviders', function (\Venne\Forms\Container $container) use($form) { $container->setCurrentGroup($form->addGroup($container->data->type)); $container->addSelect('type', 'Type')->setItems($this->securityManager->getLoginProviders(), false); $container->addText('uid', 'UID'); $container->addSubmit('remove', 'Remove')->addRemoveOnClick(); }); $form->setCurrentGroup(); $form->addSaveButton('Save'); }
public function configure(Form $form) { $route = $form->addOne('route'); $group = $form->addGroup(); $form->addText('name', 'Name'); $route->setCurrentGroup($group); $route->addTextArea('description', 'Description')->getControlPrototype()->attrs['class'] = 'input-block-level'; $route->addFileEntityInput('photo', 'Photo'); $form->addManyToOne('parent', 'Parent'); //$form->addManyToMany('types', 'Types'); $form->addTags('typesAsArray', 'Types')->setDelimiter('[;]+')->setJoiner(';'); $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $route = $form->addOne('route'); $form->addGroup(); $form->addManyToOne('parent', 'Parent'); $group = $form->addGroup('Author'); $authorName = $form->addText('author', 'Name'); $route->setCurrentGroup($group); $author = $route->addManyToOne('author', 'Author'); $authorName->addConditionOn($author, $form::FILLED)->addRule($form::EQUAL, '')->elseCondition()->addRule($form::FILLED); $author->addConditionOn($authorName, $form::FILLED)->addRule($form::EQUAL, '')->elseCondition()->addRule($form::FILLED); $form->addGroup('Text'); $form->addTextArea('text', 'Text')->setRequired(TRUE)->getControlPrototype()->attrs['class'][] = 'span12'; $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $form->addOne('page')->setCurrentGroup($form->addGroup('General'))->addCheckbox($this->getSecuredColumnName(), 'Enable permissions'); if ($form->data->page->{$this->getSecuredColumnName()}) { $permissions = $form->addContainer('permissions'); foreach ($this->getPrivileges($form) as $key => $name) { $container = $permissions->addContainer($key); $container->setCurrentGroup($form->addGroup(ucfirst($name))); $container->addCheckbox('all', 'Allow for all')->addCondition($form::EQUAL, FALSE)->toggle($container->name . $key); $group = $form->addGroup()->setOption('id', $container->name . $key); $container->setCurrentGroup($group); $container->addMultiSelect('permissions', 'Roles', $this->getRoles()); } } $form->setCurrentGroup(); $form->addSaveButton('Save'); }
/** * @param Form $form */ public function configure(Form $form) { $route = $form->addOne('route'); $group = $form->addGroup(); $form->addText('name', 'Name'); $route->setCurrentGroup($group); $route->addFileEntityInput('photo', 'Photo'); $route->addManyToOne('author', 'Author')->setDisabled(TRUE); $route->addDateTime('released', 'Release date')->addRule($form::FILLED); $route->addDateTime('expired', 'Expiry date'); $route->addTextArea('notation', 'Notation'); $form->addGroup('Event settings'); $form->addDateTime('date', 'Date')->addRule($form::FILLED); $route->setCurrentGroup($form->addGroup('Content')); $route->addContentEditor('text', NULL, NULL, 20); $form->addSaveButton('Save'); }
/** * @param Form $form */ protected function configure(Form $form) { $user = $form->addOne('user'); $group = $form->addGroup(); $user->setCurrentGroup($group); $user->addText('name', 'Name'); $user->addTextArea('notation', 'Notation', 40, 4)->getControlPrototype()->attrs['class'] = 'input-block-level'; $route = $user->addOne('route'); $route->setCurrentGroup($group); $route->addFileEntityInput('photo', 'Avatar'); $user->setCurrentGroup($form->addGroup('Password')); $user->addCheckbox('password_new', 'Change password')->addCondition($form::EQUAL, TRUE)->toggle('setPasswd'); $user->setCurrentGroup($form->addGroup()->setOption('id', 'setPasswd')); $user->addPassword('password', 'Password')->setOption('description', 'minimal length is 5 char')->addConditionOn($user['password_new'], Form::FILLED)->addRule(Form::FILLED, 'Enter password')->addRule(Form::MIN_LENGTH, 'Password is short', 5); $user->addPassword('password_confirm', 'Confirm password')->addConditionOn($user['password_new'], Form::FILLED)->addRule(Form::EQUAL, 'Invalid re password', $user['password']); $user->setCurrentGroup($form->addGroup()); }
/** * @param Form $form */ public function configure(Form $form) { $group = $form->addGroup(); $form->addText('subject', 'Subject'); $sender = $form->addOne('sender'); $sender->setCurrentGroup($group); $sender->addManyToOne('user', 'Sender'); $recipients = $form->addMany('recipients', function ($container) use($group) { $container->setCurrentGroup($group); $container->addManyToOne('user', 'Recipient'); $container->addSubmit('remove', 'Smazat')->addRemoveOnClick(); }); $recipients->setCurrentGroup($group); $recipients->addSubmit('add', 'Add')->addCreateOnClick(); $form->addGroup('Text'); $form->addTextArea('text'); $form->setCurrentGroup(); $form->addSaveButton('Save'); }
/** * @param Form $form */ protected function configure(Form $form) { $user = $form->addOne('user'); $group = $form->addGroup(); $user->setCurrentGroup($group); $user->addCheckbox('published', 'Enable'); $user->addText('email', 'E-mail')->addRule(Form::EMAIL, 'Enter email'); $user->addText('name', 'Name'); $user->addTextArea('notation', 'Notation', 40, 4)->getControlPrototype()->attrs['class'] = 'input-block-level'; $route = $user->addOne('route'); $route->setCurrentGroup($group); $route->addFileEntityInput('photo', 'Avatar'); $user->setCurrentGroup($form->addGroup('Block by key')); $user->addCheckbox('key_new', 'Enable')->addCondition($form::EQUAL, TRUE)->toggle('setKey'); $user->setCurrentGroup($form->addGroup()->setOption('id', 'setKey')); $user->addText('key', 'Authentization key')->setOption('description', 'If is set user cannot log in.'); $user->setCurrentGroup($form->addGroup('Password')); $user->addCheckbox('password_new', 'Change password')->addCondition($form::EQUAL, TRUE)->toggle('setPasswd'); $user->setCurrentGroup($form->addGroup()->setOption('id', 'setPasswd')); $user->addPassword('password', 'Password')->setOption('description', 'minimal length is 5 char')->addConditionOn($user['password_new'], Form::FILLED)->addRule(Form::FILLED, 'Enter password')->addRule(Form::MIN_LENGTH, 'Password is short', 5); $user->addPassword('password_confirm', 'Confirm password')->addConditionOn($user['password_new'], Form::FILLED)->addRule(Form::EQUAL, 'Invalid re password', $user['password']); $user->setCurrentGroup($form->addGroup('Next informations')); $user->addManyToMany('roleEntities', 'Roles'); }
/** * @param Form $form */ public function configure(Form $form) { $infoGroup = $form->addGroup('Informations'); // route $page = $form->addOne('page'); $mainRoute = $page->addOne('mainRoute'); $mainRoute->setCurrentGroup($infoGroup); $name = $mainRoute->addText('name', 'Name'); if (!$form->data->page->mainRoute->locale) { $name->addRule($form::FILLED); } $mainRoute->addHidden('localUrlTemplate')->getControlPrototype()->class[] = 'localUrlTemplate'; $input = \Nette\Utils\Html::el('input'); $input->id = 'form-checkbox'; $input->type = 'checkbox'; $htmlUrl = \Nette\Utils\Html::el('span'); $htmlUrl->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>'); $input = \Nette\Utils\Html::el('input'); $input->id = 'form-checkbox-title'; $input->type = 'checkbox'; $htmlTitle = \Nette\Utils\Html::el('span'); $htmlTitle->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>'); $input = \Nette\Utils\Html::el('input'); $input->id = 'form-checkbox-navigationTitle'; $input->type = 'checkbox'; $htmlNavigation = \Nette\Utils\Html::el('span'); $htmlNavigation->setHtml(' <label>' . $input . ' ' . ($form->getTranslator() ? $form->getTranslator()->translate('autogenerated') : 'autogenerated') . '</label>'); $mainRoute->addText('localUrl', 'URL')->addRule($form::REGEXP, "URL can not contain '/'", "/^[a-zA-z0-9._-]*\$/"); $mainRoute['localUrl']->setOption('description', $htmlUrl)->getControlPrototype()->class[] = 'localUrl'; if (!$form->data->page->mainRoute->locale) { $mainRoute['localUrl']->addRule($form::FILLED); } $mainRoute->setCurrentGroup($group = $form->addGroup()); $mainRoute->addText('title', 'Title')->setOption('description', $htmlTitle)->getControlPrototype()->class[] = 'formTitle'; $page->setCurrentGroup($group); $navigationTitle = $page->addText('navigationTitle', 'Navigation title')->setOption('description', $htmlNavigation); $navigationTitle->getControlPrototype()->class[] = 'formNavigation'; if (!$form->data->page->mainRoute->locale) { $navigationTitle->addRule($form::FILLED); } if ($form->data->page->parent) { /** @var ManyToOne $parent */ $parent = $page->addManyToOne('parent', 'Parent'); $parent->setQuery($this->getPagesQueryBuilder($form->data->page))->setPrompt(NULL); } if ($this->getUserPage()) { $mainRoute->addManyToOne('author', 'Author')->setDisabled(TRUE); } if ($this->getTagPage()) { $mainRoute->addContentTags('tags', 'Tags')->getControlPrototype()->class[] = 'input-block-level'; } $mainRoute->setCurrentGroup($form->addGroup('Layout')); if ($form->data->page->parent) { $mainRoute->addCheckbox('copyLayoutFromParent', 'Layout from parent'); } else { $mainRoute->addHidden('copyLayoutFromParent', 'Layout from parent'); } $mainRoute['copyLayoutFromParent']->addCondition($form::EQUAL, FALSE)->toggle('group-layout_' . $form->data->id); if ($form->data->page->parent) { $mainRoute->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout_' . $form->data->id)); } else { $mainRoute->setCurrentGroup($form->getForm()->addGroup('Layout')->setOption('id', 'group-layout_' . $form->data->id)); } $mainRoute->addManyToOne('layout', 'Layout'); $mainRoute->setCurrentGroup($form->addGroup()); $mainRoute->addCheckbox('copyLayoutToChildren', 'Share layout with children'); $mainRoute['copyLayoutToChildren']->addCondition($form::EQUAL, FALSE)->toggle('group-layout2_' . $form->data->id); $mainRoute->setCurrentGroup($form->getForm()->addGroup()->setOption('id', 'group-layout2_' . $form->data->id)); $mainRoute->addManyToOne('childrenLayout', 'Share new layout'); // Navigation $page->setCurrentGroup($form->addGroup('Navigation')); $page->addCheckbox('navigationShow', 'Show in navigation')->addCondition($form::EQUAL, TRUE)->toggle('form-navigation-own'); if (!$form->data->page->mainRoute->locale) { // languages /** @var $repository \DoctrineModule\Repositories\BaseRepository */ $repository = $form->mapper->entityManager->getRepository('CmsModule\\Content\\Entities\\LanguageEntity'); if ($repository->createQueryBuilder('a')->select('COUNT(a.id)')->getQuery()->getSingleScalarResult() > 1) { $page->setCurrentGroup($form->addGroup('Languages')); $page->addManyToOne("language", "Content is in")->setPrompt('shared'); } } $form->setCurrentGroup(); $form->addSaveButton('Save'); $js = ' function detectAuto() { $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").unbind("keyup keydown blur"); $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").stringToSlug({getPut: ".localUrlTemplate", space: "-" }); $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").trigger("keyup"); if($("#form-checkbox").is(":checked")) { $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").stringToSlug({getPut: ".localUrl", space: "-" }); } if($("#form-checkbox-title").is(":checked")) { $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").bind("keydown keyup blur", function(){ $(".formTitle").val($(this).val()); }); } if($("#form-checkbox-navigationTitle").is(":checked")) { $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").bind("keydown keyup blur", function(){ $(".formNavigation").val($(this).val()); }); } } function detectCheckbox() { if($("#' . $form['page']['mainRoute']['localUrlTemplate']->getHtmlId() . '").val() == $(".localUrl").val()){ $("#form-checkbox").attr("checked", true); } if($("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").val() == $(".formTitle").val()){ $("#form-checkbox-title").attr("checked", true); } if($("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").val() == $(".formNavigation").val()){ $("#form-checkbox-navigationTitle").attr("checked", true); } } $(document).ready( function() { detectAuto(); detectCheckbox(); detectAuto(); $(".localUrl").on("keydown keyup blur", function(){ $("#form-checkbox").attr("checked", false); detectCheckbox(); detectAuto(); }); $(".formTitle").on("keydown keyup blur", function(){ $("#form-checkbox-title").attr("checked", false); detectCheckbox(); detectAuto(); }); $(".formNavigation").on("keydown keyup blur", function(){ $("#form-checkbox-navigationTitle").attr("checked", false); detectCheckbox(); detectAuto(); }); $("#form-checkbox").on("click", function(event){ detectAuto(); $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").trigger("keyup"); }); $("#form-checkbox-title").on("click", function(){ detectAuto(); $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").trigger("keyup"); }); $("#form-checkbox-navigationTitle").on("click", function(){ detectAuto(); $("#' . $form['page']['mainRoute']['name']->getHtmlId() . '").trigger("keyup"); }); }); '; $script = \Nette\Utils\Html::el('script'); $script->setHtml($js); $form['page']['mainRoute']['name']->setOption('description', $script); }