protected function createComponentPageForm() { $form = new Form(); $form->setTranslator($this->translator->domain('pageEditForm')); $form->getElementPrototype()->id = 'page-form'; $form->addText('title', 'title.label', null, Page::LENGTH_TITLE)->setMaxLength(Page::LENGTH_TITLE)->setRequired('title.messages.required')->setAttribute('data-text-length', Page::LENGTH_TITLE)->addRule(Form::MAX_LENGTH, new Phrase('title.messages.maxLength', ['numChars' => Page::LENGTH_TITLE]), Page::LENGTH_TITLE); $form->addText('publishedAt', 'publishedAt.label', null, 16)->setHtmlId('datetimepicker')->setRequired('publishedAt.messages.required')->addCondition(Form::FILLED)->addRule(Form::MAX_LENGTH, new Phrase('publishedAt.messages.maxLength', ['numChars' => 16]), 16); $form->addTextArea('intro', 'intro.label', null, 7)->setMaxLength(Page::LENGTH_INTRO)->setRequired('intro.messages.required')->setAttribute('data-text-length', Page::LENGTH_INTRO)->addRule(Form::MAX_LENGTH, new Phrase('intro.messages.maxLength', ['numChars' => Page::LENGTH_INTRO]), Page::LENGTH_INTRO); $form->addTextArea('text', 'text.label', null, 25); //->setRequired('text.messages.required'); $form->addText('url', 'url.label', null, 255); $form->addSelect('lang', 'lang.label')->setItems($this->availableLocales)->setDefaultValue($this->defaultLocale); if (isset($this->page)) { $form['lang']->setDisabled(); //$form['lang']->setOmitted(); } $form->addCheckbox('allowedComments', 'allowedComments.label')->setDefaultValue(true); $form->addText('keywords', 'keywords.label'); $form->addText('description', 'description.label'); $form->addSubmit('saveAndPublish', 'saveAndPublish.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAndPublish.title'))->onClick[] = [$this, 'processPageSavingAndPublishing']; $form->addSubmit('saveAsDraft', 'saveAsDraft.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAsDraft.title'))->onClick[] = [$this, 'processPageSavingAsDraft']; if (!$this->authorizator->isAllowed($this->user, 'page', 'create') or !$this->authorizator->isAllowed($this->user, 'page', 'edit')) { $form['saveAndPublish']->setDisabled(); $form['saveAsDraft']->setDisabled(); } $form->addProtection(); return $form; }
protected function createComponentArticleForm() { $form = new UI\Form(); $form->addText('name', 'Název článku:')->setRequired(); $form->addUpload('image', 'Obrázek JPG')->addCondition($form::FILLED)->addRule($form::IMAGE, 'Zvolený soubor není obrázek.')->addRule($form::MAX_FILE_SIZE, 'Maximální velikost souboru je 5 MB.', 6 * 1024 * 1024); $form->addTextArea('annotation', 'Annotace:')->setAttribute('class', 'tinyMCE'); $form->addTextArea('text', 'Článek:')->setAttribute('class', 'tinyMCE'); $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary'); $form->onSuccess[] = array($this, 'articleFormSucceeded'); return $form; }
protected function createComponentArticleForm() { $form = new UI\Form(); $form->addText('name', 'Název článku:')->setRequired(); $form->addText('menu', 'Položka menu:'); $form->addText('url', 'Odkaz jinam než na svůj')->setType('url'); $form->addTextArea('annotation', 'Annotace:')->setAttribute('class', 'tinyMCE'); $form->addTextArea('text', 'Článek:')->setAttribute('class', 'tinyMCE'); $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary'); $form->onSuccess[] = array($this, 'articleFormSucceeded'); return $form; }
public function create() { $form = new Form(); $form->enableLocalized(); $form->addText('name')->setRequired('errors.fill_role_name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'role_name'); $form->addTextArea('access', 'role_access')->setAttribute('class', 'form-control'); $form->addTextArea('description', 'description')->setAttribute('class', 'form-control'); $form->addTextArea('access_ban', 'access_ban')->setAttribute('class', 'form-control'); $form->addSubmit('submit', 'add')->setAttribute('class', 'btn btn-primary btn-purple btn-flat'); $form->onSuccess[] = $this->success_form_add; return $form; }
/** * @return Form */ public function createComponentForm() { $form = new Form(); $form->addText('name', 'Name:', null, 45)->setRequired('Please fill your name or nick name.')->setValue('Anonymous'); $form->addTextArea('pros', 'Pros:', null, 5); $form->addTextArea('cons', 'Cons:', null, 5); $form['pros']->addConditionOn($form['cons'], Form::BLANK, TRUE)->setRequired('Please fill at least Pros or Cons.'); $form['cons']->addConditionOn($form['pros'], Form::BLANK, TRUE)->setRequired('Please fill at least Pros or Cons.'); $form->addRadioList('rating', 'Rating:', [1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5])->setRequired('Please select your rating'); $form->addSubmit('send', 'Save Rating'); $form->onSuccess[] = array($this, 'formSucceeded'); return $form; }
/** * @return \Nette\Application\UI\Form */ public function create() { $form = new Form(); $form->addGroup($this->performance ? "Upravit představení" : "Přidat představení"); $form->addTextArea("songAuthor", "Autor skladby:")->setRequired("Vyplňte prosím autora skladby"); $form->addTextArea("songName", "Jméno skladby:")->setRequired("Vyplňte prosím jméno skladby"); $form->addTextArea("note", "Poznámka:"); $form->addSubmit("send", $this->performance ? "Upravit představení" : "Přidat představení"); $form->onSuccess[] = $this->processForm; if ($this->performance) { $form->setDefaults(["songAuthor" => $this->performance->songAuthor, "songName" => $this->performance->songName, "note" => $this->performance->note]); } return $form; }
protected function createComponentClanek() { $form = new Form(); $form->addHidden("id"); $form->addText("titulek", "Titulek")->addRule(Form::MAX_LENGTH, "Titulek je příliš dlouhý", 64); $form->addText("autor", "Autor")->addRule(Form::MAX_LENGTH, "Autor je příliš dlouhý", 64); $form->addSelect("kategorie_id", "Kategorie", $this->kategorie->getPairs()); $form->addTextArea("perex", "Perex"); $form->addSelect("obrazek_id", "Obrázek", $this->upload->getPairs())->setPrompt("-- bez obrázku --"); $form->addTextArea("text", "Text"); $form->addTextArea("stitky_text", "Štítky"); $form->addText("skupina", "Skupina"); $form->addSubmit("save", "Uložit"); $form->onSuccess[] = $this->saveClanek; return $form; }
protected function createComponentAddInterpret() { $form = new Form(); $form->addText('nazev', 'Název interpreta')->setRequired('Je třeba zadat jméno interpreta.'); $form->addSelect('interpret_id', 'Alias pro', $this->interpreti->findAll()->order('nazev')->fetchPairs('id', 'nazev'))->setPrompt('Vyberte alias'); $form->addTextArea('desc', 'About'); $form->addHidden('id'); $form->addSubmit('send', 'Přidat'); $form->onSuccess[] = function ($frm) { $values = $frm->values; if ($values->id) { $this->interpreti->find($values->id)->update($values); $this->logger->log('Interpret', 'edit', "%user% upravila(a) interpreta {$values->nazev}"); $msg = $this->flashMessage("Interpret '{$values->nazev}' editován.", 'success'); $msg->title = 'A je tam!'; $msg->icon = 'check'; } else { $r = $this->interpreti->add($values->nazev, $values->desc, $values->interpret_id, $this->user); $this->logger->log('Interpret', 'create', "%user% vytvořila(a) interpreta {$values->nazev}"); $msg = $this->flashMessage("Interpret '{$values->nazev}' přidán.", 'success'); $msg->title = 'A je tam!'; $msg->icon = 'check'; $msg->html = Html::el('a')->setText('Přidat další')->setHref($this->link('editor')); if ($this->action == 'editor') { $this->redirect('this', [$r->id]); } } $this->redirect('this'); }; return $form; }
/** * @return Form */ public function create($otherUser = '', $privilegesEdit = false) { $form = new Form(); if (!empty($otherUser)) { $user = $otherUser; $form->addHidden('id', $otherUser->id); } else { $user = $this->user; } $form->addUpload('photo', 'Fotka')->addRule($form::MAX_FILE_SIZE, 'Maximální velikost fotky je 10MB', 80000000); $form->addText('nickName', 'Přihlašovací jméno')->setValue($user->nickName)->setOption('description', Html::el('p')->setHtml('Pokud chcete můžete pro jednodušší přihlašování zadat jméno'))->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Jméno musí mít alespoň %d znaky', 3); $form->addText('name', 'Jméno k zobrazení')->setValue($user->name); if ($privilegesEdit) { $form->addText('title', 'Titul')->setValue($user->title)->setOption('description', Html::el('p')->setHtml('Titul měnitelný administrátorem přidaný před jméno')); } $date = $this->parseDateForm(); $form->addSelect('day', 'Den narození', $date['days'])->setValue($date['day']); $form->addSelect('month', 'Měsíc narození', $date['months'])->setValue($date['month']); $form->addSelect('year', 'Rok narození', $date['years'])->setValue($date['year']); $form->addSelect('gender', 'Pohlaví', ['ma' => 'Muž', 'fe' => 'Žena', 'no' => 'Neuvedeno'])->setValue($user->gender); $form->addCheckbox('wall', 'Povolit zeď')->setValue($user->wall == 1 ? true : false); $form->addCheckbox('mailList', 'Posílat od nás maily')->setValue($user->mailList == 1 ? true : false); $form->addTextArea('about', 'O mě')->setValue($user->about); if ($privilegesEdit) { $this->editPrivileges($form, $user->permissions); } $form->addSubmit('submit', 'Uložit'); $form->addProtection('Vypršel časový limit, odešlete formulář znovu'); $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
protected function createComponentUserEditor() { $form = new Form(); $form->addText('username', 'Uživatelské jméno')->setRequired('Zadejte uživatelské jméno'); $form->addText('realname', 'Skutečné jméno'); $form->addSelect('role', 'Role', $this->perms->getRoles())->setPrompt('Vyberte roli')->setRequired('Musíte vybrat roli uživatele'); $form->addText('email', 'Email')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Zadejte platnnou emailovou adresu'); $form->addPassword('password', 'Heslo')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Heslo musí mít minimálně %s znaků', 6); $form->addPassword('password_verify', 'Ověření hesla')->setOmitted()->addConditionOn($form['password'], Form::FILLED)->addRule(Form::EQUAL, 'Hesla se neshodují', $form['password']); $form->addText('twitter_acc', 'Twitter'); $form->addText('www', 'Homepage (WWW)')->addCondition(Form::FILLED)->addRule(Form::URL, 'Zadejte platnou URL'); $form->addTextArea('about', 'Krátce o uživateli'); $form->addHidden('id')->setRequired('Vyžadován identifikátor'); $form->onSuccess[] = function (Form $f) { $val = $f->values; if (empty($val->password)) { unset($val->password); } else { $this->users->changePassword($val->id, $val->password); unset($val->password); } $this->users->update($val->id, $val); $this->logger->log('User', 'edit', "%user% editoval(a) profil uživatele {$val->username}"); $msg = $this->flashMessage("Profil uživatele '{$val->username}' upraven.", 'success'); $msg->title = 'A je tam!'; $msg->icon = 'check'; $this->redirect('this'); }; $form->addSubmit('send', 'Uložit'); return $form; }
public function createComponentRaceForm() { $validator = function ($item) { return $this->race->freeRaceid($item->value); }; $form = new Form(); $i = $form->addText('raceid', 'ID závodu:'); if ($this->getAction() == 'add') { $i->setRequired('ID závodu je povinné')->addRule(Form::LENGTH, 'Délka ID musí být 4 - 8 znaků', array(4, 8))->addRule($validator, 'ID je již použito.'); } else { $i->setDisabled(TRUE); } $form->addText('name', 'Název:'); $form->addDateTimePicker('datetime_0', 'Datum a čas:')->setRequired('Datum a čas jsou povinné.'); $form->addSelect('type', 'Typ závodu', self::$race_type); $form->addSelect('opt_preftype', 'Druh závodu', self::$race_kind); $form->addSelect('opt_incomplete', 'Při chybějící kontrole', self::$inco_list); $form->addCheckbox('opt_autocat', 'Automatická kategorie'); $form->addCheckbox('opt_namefrsi', 'Doplnit jméno z SI čipu'); $form->addCheckbox('opt_addnew', 'Hodnotit i nepřihlášené'); $form->addTextArea('descr', 'Popis:'); $form->addSubmit('send', 'OK'); $form->addSubmit('cancel', 'Zpět')->setValidationScope(false)->onClick[] = [$this, 'formCancelled']; if ($this->getAction() == 'add') { $form->onSuccess[] = [$this, 'addRaceFormSucceeded']; } else { $form->onSuccess[] = [$this, 'editRaceFormSucceeded']; } $form->setRenderer(new Bs3FormRenderer()); return $form; }
protected function createComponentCourseRegistration() { $msgNameReq = "Zadejte prosím jméno a příjmení."; $msgEmailReq = "Zadejte prosím emailovou adresu."; $msgPhoneReq = "Zadejte prosím telefonní číslo."; $msgPhoneBad = "Telefon není správně vyplněn."; $msgDateReq = "Vyberte prosím termín akce."; $persons = array('1 osoba', '2 osoby', '3 osoby', '4 osoby', '5 osob'); $dates = array(); foreach ($this->context->parameters['courses'][$this->course]['dates'] as $date) { $dates[] = $this->template->date($date['date'], '%d.%m.%Y'); } $form = new Form(); $form->addText('name', 'Jméno', NULL, 60)->setAttribute('placeholder', 'Jméno a příjmení')->setAttribute('tabindex', 1)->addRule(~$form::EQUAL, $msgNameReq, $form['name']->control->attrs['placeholder'])->setRequired($msgNameReq); $form->addText('email', 'Email', NULL, 40)->setAttribute('placeholder', 'Email')->setAttribute('tabindex', 2)->addRule(~$form::EQUAL, $msgEmailReq, $form['email']->control->attrs['placeholder'])->setRequired($msgEmailReq)->addRule(Form::EMAIL, '%label není správně vyplněn.'); $form->addText('phone', 'Telefon', NULL, 9)->setAttribute('placeholder', 'Telefon')->setAttribute('tabindex', 3)->addRule(~$form::EQUAL, $msgPhoneReq, $form['phone']->control->attrs['placeholder'])->setRequired($msgPhoneReq)->addRule(Form::INTEGER, $msgPhoneBad)->addRule(Form::LENGTH, $msgPhoneBad, 9); $form->addSelect('date', 'Termín konání')->setPrompt('Zvolte termín konání')->setItems($dates)->setRequired($msgDateReq); if (count($dates) == 1) { $form['date']->setDefaultValue(0); } $form->addSelect('person', 'Počet')->setItems($persons, FALSE); $form->addTextArea('note', 'Poznámka', NULL)->setAttribute('placeholder', 'Jakýkoli dotaz nebo zpráva.')->setAttribute('tabindex', 4)->addRule(Form::MAX_LENGTH, 'Poznámka může obsahovat maximálně 1000 znaků.', 1000); $form->addSubmit('send', 'Odeslat')->setAttribute('tabindex', 5)->setAttribute('class', 'button'); $form->addSubmit('storno', 'Storno')->setAttribute('tabindex', 6)->setValidationScope(NULL)->setAttribute('class', 'button'); $form->addHidden('spamtest')->addRule($form::EQUAL, 'Robot', array(NULL)); $form->onSuccess[] = callback($this, 'submitRegistration'); return $form; }
protected function createComponentPageEditor() { $form = new Form(); $form->addText('name', 'Název stránky')->setRequired(); $form->addText('heading', 'Nadpis')->setRequired(); $form->addTextArea('body', 'Obsah'); $form->addCheckbox('hidden', 'Výstřižek stránky'); $form->addHidden('id'); $form->addSubmit('send', 'Uložit'); $form->onSuccess[] = function (Form $f) { $val = $f->values; //Update page if ($val->id) { $this->pages->find($val->id)->update($val); $msg = $this->flashMessage("Stránka byla upravena", 'success'); $msg->title = 'A je tam!'; $msg->icon = 'check'; $this->logger->log('CMS', 'edit', "%user% uprvila(a) stránku {$val->name}"); } else { $r = $this->pages->create($val); $msg = $this->flashMessage("Stránka byla vytvořena.", 'success'); $msg->title = 'A je tam!'; $msg->icon = 'check'; $this->redirect('this', ['id' => $r->id]); $this->logger->log('CMS', 'create', "%user% vytvořil(a) stránku {$val->name}"); } $this->redirect('this'); }; return $form; }
public function __construct(DbTable\Oznam $oznam, DbTable\Registracia $registracia, DbTable\Ikonka $ikonka, User $user) { $this->oznam = $oznam; $this->ikonka = $ikonka; $this->urovneReg = $registracia->hladaj_urovne(0, $user->isLoggedIn() ? $user->getIdentity()->id_registracia : 0)->fetchPairs('id', 'nazov'); } /** * Formular pre editaciu oznamu * @param int $oznam_ucast Povolenie potvrdenia ucasti * @param boolean $send_e_mail_news Povolenie zasielania info e-mailov * @param boolean $oznam_title_image_en Povolenie titulneho obrazka * @param string $nazov_stranky Nazov stranky * @return Form */ public function create($oznam_ucast, $send_e_mail_news, $oznam_title_image_en, $nazov_stranky) { $form = new Form(); $form->addProtection(); $form->addHidden("id"); $form->addHidden("id_user_profiles"); $form->addHidden("datum_zadania"); $form->addDatePicker('datum_platnosti', 'Dátum platnosti')->addRule(Form::FILLED, 'Dátum platnosti musí byť zadaný!'); $form->addText('nazov', 'Nadpis:', 50, 80)->addRule(Form::MIN_LENGTH, 'Nadpis musí mať spoň %d znakov!', 3)->setRequired('Názov musí byť zadaný!'); $form->addSelect('id_registracia', 'Povolené prezeranie pre min. úroveň:', $this->urovneReg); if ($oznam_ucast) { $form->addCheckbox('potvrdenie', ' Potvrdenie účasti'); } else { $form->addHidden('potvrdenie'); } if ($send_e_mail_news) { $form->addCheckbox('posli_news', ' Posielatie NEWS o tejto aktualite'); } else { $form->addHidden("posli_news", FALSE); } if (!$oznam_title_image_en) { //$this->oznam_title_image_en
protected function createComponentCommentForm() { $form = new Form(); $form->addTextArea('message'); $form->addSubmit('send', 'Send'); $form->onSuccess[] = $this->processCommentForm; return $form; }
/** * @return Form */ public function create() { $form = new Form($this->parent, "contactForm"); $form->addText("email", "E-mail")->setType("email")->addRule(Form::REQUIRED, "Vyplňte prosím Váš e-mail.")->addRule(Form::EMAIL, "Vyplňte prosím Váš e-mail."); $form->addTextArea("content", "Text")->addRule(Form::REQUIRED, "Vyplňte prosím text."); $form->addSubmit("send", "Odeslat")->setAttribute("class", "btn btn-primary"); return $form; }
protected function createComponentReplyForm() { $form = new Nette\Application\UI\Form(); $form->addTextArea('content', 'Your Reply:')->setRequired(); $form->addSubmit('send', 'Reply'); $form->onSuccess[] = $this->replyFormSucceeded; return $form; }
/** * @return Form */ protected function createComponentForm() { $form = new Form(); $form->addText('description', 'Short description')->setRequired('Write short description what you are changing'); $form->addTextArea('queries', 'SQL queries')->setRequired('Complete your query')->setAttribute('rows', 10); $form->addSubmit('send', 'Save'); $form->onSuccess[] = [$this, 'processForm']; return $form; }
/** * @Actions contact */ protected function createComponentHelpForm() { $form = new Form(); $form->addText('subject', 'Předmět:', 27, 80)->setRequired('Vyplňte prosím předmět Vaší zprávy.')->getControlPrototype()->class = 'w340'; $form->addTextArea('text', 'Zpráva:', 40, 10)->setRequired('Vyplňte prosím text Vaší zprávy.')->getControlPrototype()->class = 'w360'; $form->addSubmit('send', 'Odeslat dotaz')->setOmitted(); $form->onSuccess[] = $this->proccessHelpForm; return $form; }
protected function createComponentCreateTopicForm() { $form = new Nette\Application\UI\Form(); $form->addText('title', 'Title: ')->setRequired(); $form->addTextArea('content', 'Content:')->setRequired(); $form->addSubmit('send', 'Create'); $form->onSuccess[] = $this->createTopicFormSucceeded; return $form; }
protected function createComponentPasteItForm() { $form = new Nette\Application\UI\Form(); $form->addText("id_type", "Typ:"); $form->addTextArea("text", "Text:")->setRequired(); $form->addSubmit("send", "PasteIt !"); $form->onSuccess[] = $this->pasteItFormSucceeded; return $form; }
protected function createComponentArticleForm() { $form = new Form(); $form->addText('title', 'Titulek'); $form->addTextArea('content', 'Obsah:'); $form->addSubmit('send', 'Send'); $form->onSuccess[] = $this->processArticleForm; return $form; }
protected function createComponentPasteForm() { $form = new UI\Form(); $form->addTextArea('note', 'Paste:')->setAttribute('onkeyup', 'adjust(this)'); $form['note']->getControlPrototype()->addClass('add-form'); $form->addSubmit('login', 'Odeslat'); $form->onSuccess[] = array($this, 'pasteFormSucceeded'); return $form; }
protected function createComponentPostForm() { $form = new Form(); $form->addText('title', 'Titulek:')->setRequired(); $form->addTextArea('content', 'Obsah:')->setRequired(); $form->addSubmit('send', 'Uložit a publikovat'); $form->onSuccess[] = array($this, 'postFormSucceeded'); return $form; }
public function createComponentForm($name) { $form = new Form($this, $name); $form->addTextArea("html", "Upravte data", 80, 50)->controlPrototype->class[] = "tinymce"; $form->addSubmit("doPDFka", "Do PDFka!"); $appDir = Nette\Environment::getVariable('appDir'); $form->setDefaults(array("html" => $this->createTemplate()->setFile($appDir . "/templates/Homepage/pdf-source.latte")->__toString())); $form->onSuccess[] = array($this, "onSubmit"); }
public function create() { $form = new Form(); $form->addText('title', 'Napis')->setRequired('Musíte zadat titulek'); $form->addTextArea('text', 'Text')->setRequired('Musíte zadat text'); $form->addText('keyWords', 'Klíčová slova'); $form->addSubmit('submit', 'Odeslat'); return $form; }
protected function createComponentPostForm() { $form = new UI\Form(); $form->addText('title', 'Your title:')->setRequired(); $form->addTextArea('content', 'Content:')->setRequired(); $form->addSubmit('save', 'Publish Post'); $form->onSuccess[] = array($this, 'postFormSucceeded'); return $form; }
/** * @return Form */ function create() { $form = new Form(); $form->addUpload('file', 'Select file')->setRequired(); $form->addTextArea('note', 'Your note'); $form->addSubmit('process', 'Upload'); $form->onSuccess[] = $this->solutionFormSucceeded; return BootstrapForm::makeBootstrap($form); }
public function createComponentPostForm() { $form = new Form(); $form->addText("title", "Titulek:")->setRequired(); $form->addTextArea("content", "Obsah:")->setRequired(); $form->addSubmit("send", "Uložit a publikovat"); $form->onSuccess[] = array($this, "postFormSucceeded"); return $form; }
protected function createComponentManufacturerForm() { $form = new UI\Form(); $form->addText('name', 'Název výrobce:')->setRequired(); $form->addTextArea('description', 'Popis:')->setAttribute('class', 'tinyMCE'); $form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary'); $form->onSuccess[] = array($this, 'manufacturerFormSucceeded'); return $form; }