/** * Edit hlavne menu form component factory. * @return Nette\Application\UI\Form */ public function create($iko, $upload_size) { $form = new Form(); $form->addProtection(); $form->addHidden("id"); $form->addHidden("id_lang"); $form->addHidden("spec_nazov"); $form->addUpload('title_image', 'Titulný obrázok:')->setOption('description', 'Odporúčaný rozmer obrázku je: 90x70px alebo násobky tejto veľkosti. Inak môže dôjsť k deformácii alebo orezaniu obrázku pri ukladaní!')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'Titulný obrázok musí byť JPEG, PNG alebo GIF.')->addRule(Form::MAX_FILE_SIZE, 'Maximálna veľkosť súboru je 64 kB.', 64 * 1024); $form->addText('nazov', 'Názov produktu:', 50, 50)->setRequired('Názov musí byť zadaný!'); $form->addRadioList('tepkat', 'Tepelná kategória:', $iko)->getSeparatorPrototype()->setName(NULL); $form->addText('vyska', 'Výška[mm]:', 5, 5)->addRule(Form::RANGE, 'Výška musí byť v rozsahu od %d do %d mm!', array(0, 4000))->setRequired('Výška musí byť zadaná!'); $form->addText('sirka', 'Šírka[mm]:', 5, 5)->addRule(Form::RANGE, 'Šírka musí byť v rozsahu od %d do %d mm!', array(0, 2000))->setRequired('Šírka musí byť zadaná!'); $form->addText('hlbka', 'Hĺbka[mm]:', 5, 5)->addRule(Form::RANGE, 'Hĺbka musí byť v rozsahu od %d do %d mm!', array(0, 2000))->setRequired('Hĺbka musí byť zadaná!'); $form->addText('hmotnost', 'Hmotnosť[kg]:', 5, 5)->addRule(Form::RANGE, 'Hmotnosť musí byť v rozsahu od %d do %d kg!', array(0, 3500))->setRequired('Hmotnosť musí byť zadaná!'); $form->addText('bottom_plinth_weight', 'Hmotnosť spodného podstavca[kg]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Hmotnosť spodného podstavca musí byť v rozsahu od %d do %d kg!', array(0, 2000)); $form->addCheckbox('copatible_aurum', ' Kompatibilné s Aurum Pellet Unit'); $form->addText('termal_energy', 'Tepelná energia[kWh]:', 5, 5)->addRule(Form::RANGE, 'Tepelná energia musí byť v rozsahu od %d do %d kWh!', array(0, 200))->setRequired('Tepelná energia musí byť zadaná!'); $form->addText('heating_time', 'Čas spaľovania[h:min]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Čas spaľovania musí byť zapísaný v tvare napr.:02:30', '([0-9]\\s*){2}:([0-9]\\s*){2}'); $form->addText('heating_occasion', 'Max. množstvo dreva[kg]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Max. množstvo dreva musí byť v rozsahu od %d do %d kg!', array(0, 100)); $form->addText('forewood_lenght', 'Dĺžka dreva do rúry na pečenie[cm]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Dĺžka dreva do rúry na pečenie musí byť v rozsahu od %d do %d cm!', array(0, 100)); $form->addText('firewood_lenght', 'Dĺžka dreva[cm]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Dĺžka dreva musí byť v rozsahu od %d do %d cm!', array(0, 100)); $form->addText('nominal_heat_output', 'Nominálny tepelný výkon[kW]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Nominálny tepelný výkon musí byť v rozsahu od %d do %d kW!', array(0, 15)); $form->addText('nominal_heat_time', 'Nominálny čas[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Nominálny čas musí byť v rozsahu od %d do %d h!', array(0, 50)); $form->addText('heat_release_time100', 'Tepelná akumulačná kapacita, 100 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 50)); $form->addText('heat_release_time50', 'Tepelná akumulačná kapacita, 50 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 100)); $form->addText('heat_release_time25', 'Tepelná akumulačná kapacita, 25 percent maximálneho výkonu[h]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Tepelná akumulačná kapacita musí byť v rozsahu od %d do %d h!', array(0, 100)); $form->addText('efficiency', 'Účinnosť[%]:', 5, 5)->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Účinnosť musí byť v rozsahu od %d do %d %!', array(0, 100)); $form->addUpload('pec_pdf', 'Katalógový list vo formáte pdf:')->setOption('description', sprintf('Max veľkosť prílohy v bytoch %s kB', $upload_size / 1024))->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Katalógový list musí byť vo formáte pdf!', 'application/pdf')->addRule(Form::MAX_FILE_SIZE, 'Max veľkosť prílohy može byť v bytoch %d B', $upload_size); $form->addSubmit('uloz', 'Ulož produkt');
/** * @param DbTable\Users $users * @param DbTable\User_profiles $users_profiles * @param DbTable\Registracia $registracia * @param \App\AdminModule\Presenters\Forms\User\User $user */ public function __construct(DbTable\Users $users, DbTable\User_profiles $users_profiles, DbTable\Registracia $registracia, User $user) { $this->users = $users; $this->users_profiles = $users_profiles; $this->id_reg = $user->isLoggedIn() ? $user->getIdentity()->id_registracia : 0; $this->urovneReg = $registracia->hladaj_urovne(0, $this->id_reg)->fetchPairs('id', 'nazov'); //Hodnoty id=>nazov pre formulare z tabulky registracia } /** * Edit hlavne menu form component factory. * @return Nette\Application\UI\Form */ public function create($user_view_fields) { $form = new Form(); $form->addProtection(); $form->addHidden('id'); $form->addHidden('id_users'); $form->addHidden('created'); $form->addHidden('modified'); $form->addText('meno', 'Meno:', 50, 80)->addRule(Form::MIN_LENGTH, 'Meno musí mať spoň %d znakov!', 3)->setRequired('Meno musí byť zadané!'); $form->addText('priezvisko', 'Priezvisko:', 50, 80)->addRule(Form::MIN_LENGTH, 'Priezvisko musí mať spoň %d znakov!', 3)->setRequired('Priezvisko musí byť zadané!'); $form->addText('username', 'Užívateľské meno', 50, 50)->addRule(Form::MIN_LENGTH, 'Užívateľské meno musí mať aspoň %s znakov', 3)->setRequired('Užívateľské meno musí byť zadané!'); $form->addText('email', 'E-mailová adresa', 50, 50)->setType('email')->addRule(Form::EMAIL, 'Musí byť zadaná korektná e-mailová adresa(napr. janko@hrasko.sk)')->setRequired('E-mailová adresa musí byť zadaná!'); if ($this->id_reg > 2) { $form->addSelect('id_registracia', 'Úroveň registrácie člena:', $this->urovneReg); } if ($user_view_fields["rok"]) {
public function createComponentNotehpForm() { $httpRequest = $this->context->httpRequest; $orderId = $httpRequest->getQuery('noteId'); $this->note = $this->context->createNote()->getNote()->where('active', 1)->where('order', $orderId)->limit(1)->order('id DESC')->fetch(); if ($this->note == false) { $id = NULL; $heading = NULL; $title = NULL; $order = $orderId; $text = NULL; } else { $id = $this->note->id; $heading = $this->note->heading; $title = $this->note->title; $order = $orderId; $text = $this->note->text; } $form = new Form(); $form->addHidden('id')->setDefaultValue($id); $form->addHidden('order')->setDefaultValue($order); $form->addText('heading', '*Nadpis: ', 40)->addRule(Form::FILLED, 'Nadpis musí být vyplněn!')->setDefaultValue($heading); $form->addText('title', '*Titul: ', 100)->addRule(Form::FILLED, 'Titul musí být vyplněn!')->setDefaultValue($title); $form->addTextArea('text', '*Text: ', 76, 10)->addRule(Form::FILLED, 'Text musí být vyplněn!')->setDefaultValue($text); $form->addCheckbox('active', 'Viditelný')->setDefaultValue(true); $form->addSubmit('send', 'Uložit zprávu'); $form->onSuccess[] = callback($this, 'notehpFormSubmitted'); return $form; }
/** * Formular pre editaciu udajov * @param boolean $admin * @param array $druh * @return Nette\Application\UI\Form */ public function create($admin, $druh, $ur_reg) { $this->ur_reg = $ur_reg; $form = new Form(); $form->addProtection(); $form->addGroup(); $form->addHidden('id'); $form->addHidden('id_udaje_typ'); if ($admin) { $form->addText('nazov', 'Názov prvku:', 20, 20)->addRule(Form::MIN_LENGTH, 'Názov musí mať spoň %d znaky!', 2)->setAttribute('class', 'heading')->setRequired('Názov musí byť zadaný!'); $form->addText('comment', 'Komentár k hodnote :', 90, 255)->addRule(Form::MIN_LENGTH, 'Komentár musí mať spoň %d znaky!', 2)->setRequired('Komentár musí byť zadaný!'); } else { $form->addHidden('nazov'); $form->addHidden('comment'); } $form->addText('text', 'Hodnota prvku:', 90, 255)->setRequired('Hodnota prvku musí byť zadaná!'); if ($admin) { $form->addCheckbox('spravca', ' Povolená zmena pre správcu')->setDefaultValue(1); $form->addCheckbox("druh_null", " Hodnota druhu je NULL")->setDefaultValue(1)->addCondition(Form::EQUAL, TRUE)->toggle("druh", FALSE); $form->addGroup()->setOption('container', Html::el('fieldset')->id("druh")); $form->addSelect('id_druh', 'Druhová skupina pre nastavenia:', $druh)->setDefaultValue(1); $form->setCurrentGroup(NULL);
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
public function create($underSection, $underSubSection) { $form = new Form(); $form->addHidden('underSection', $underSection); $form->addHidden('underSubSection', $underSubSection); $form->addText('name', 'Jméno:')->setRequired('Zadejte jméno')->setAttribute('placeholder', 'Jméno'); $form->addTextArea('description', 'Popis: ')->setAttribute('placeholder', 'Popis'); $form->addSubmit('submit', 'Přidat seriál'); return $form; }
/** * Pridanie/editacia prispevku form component factory. * @return Nette\Application\UI\Form */ protected function createComponentKomentarForm() { $form = new Form(); $form->addProtection(); $form->addTextArea('text', $this->trLang('KomentarForm_text'))->setAttribute('rows', $this->textA_rows)->setAttribute('cols', $this->textA_cols); $form->addHidden('id'); $form->addHidden('id_user_profiles'); $form->addSubmit('uloz', $this->trLang('KomentarForm_uloz')); $form->onSuccess[] = [$this, 'onZapisKomentar']; return $form; }
public function create() { $form = new Form(); $form->getElementPrototype()->class("ajax"); $form->addText("name", "Název")->addRule(Form::MAX_LENGTH, "Maximální délka názvu může být %d znaků.", Category::MAX_NAME_LENGTH)->setRequired("Zadej prosím název kategorie."); $form->addHidden("visible", 1); $form->addHidden("categoryId", 0); $form->addSubmit("submit")->setAttribute("class", "btn btn-default"); $form->onSuccess[] = $this->addCategoryFormSucceeded; return $form; }
protected function createComponentKomentar() { $form = new Form(); $form->addText("jmeno", "Jméno")->addRule(Form::FILLED, "Vyplňte prosím jméno.")->addRule(Form::MAX_LENGTH, "Jméno je příliš dlouhé. Maximální délka jména je 64 znaků.", 64); $form->addTextArea("text", "Komentář")->addRule(Form::FILLED, "Vyplňte prosím text komentáře.")->addRule(Form::MAX_LENGTH, "Text komentáře je příliš dlouhý. Maximální délka textu je 1000 znaků.", 1000); $form->addHidden("skryte"); $form->addSubmit("komentuj", "Přidat komentář"); $form->addHidden("clanek_id")->setValue($this->id); $form->onSuccess[] = $this->komentar; return $form; }
protected function createComponentPrispevekForm() { $form = new Form(); $form->addTextArea('text', 'Text příspěvku', NULL, 10)->setRequired('Prosím zadejte text příspěvku.'); $form->addSubmit('send', 'Uložit příspěvek'); $form->addHidden('parent'); $form->addHidden('id'); $form->onSuccess[] = array($this, 'prispevekFormSucceeded'); //$form->onValidate[] = array($this, 'nastenkaFormValidate'); $form->setRenderer(new BootstrapRenderer()); return $form; }
protected function createComponentNewPasswordForm() { $form = new Form(); $passwordLabel = $this->translator->translate('messages.app.newPassword'); $form->addPassword('password', $passwordLabel); $form->addHidden('email'); $form->addHidden('token'); $submitLabel = $this->translator->translate('messages.app.setNewPassword'); $form->addSubmit('submit', $submitLabel); $form->onSuccess[] = array($this, 'newPasswordFormSucceeded'); return $form; }
protected function createComponentNfsEditForm() { $form = new Form(); $form->addCheckbox('export', 'Exportovat tuto složku přes NFS?'); $form->addText('ips', 'Adresy k exportu')->addRule(Form::FILLED, 'Alespoň jedna adresa musí být vyplněna'); $form->addHidden('folder_id'); $form->addHidden('id'); $form->addSubmit('send', 'Uložit'); $form->onSuccess[] = array($this, 'NfsEditFormSucceeded'); $form->onValidate[] = array($this, 'NfsEditFormValidate'); $form->setRenderer(new BootstrapRenderer()); return $form; }
/** @var string */ private $avatar_path; /** @var string */ private $www_dir; /** * @param DbTable\Hlavne_menu $hlavne_menu */ public function __construct(DbTable\Hlavne_menu $hlavne_menu) { $this->hlavne_menu = $hlavne_menu; } /** * Formular pre pridanie a editaciu titulneho obrazku polozky. * @return Nette\Application\UI\Form */ public function create($avatar_path, $www_dir)
protected function createComponentFtpEditForm() { $form = new Form(); $form->addCheckbox('export', 'Exportovat tuto složku na FTP?'); $form->addText('username', 'Přihlašovací jméno')->addRule(Form::FILLED, 'Přihlašovací jméno musí být zadáno'); $form->addText('password', 'Heslo')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň 8 znaků', 8); $form->addHidden('folder_id'); $form->addHidden('id'); $form->addSubmit('send', 'Uložit'); $form->onSuccess[] = array($this, 'FtpEditFormSucceeded'); $form->onValidate[] = array($this, 'FtpEditFormValidate'); $form->setRenderer(new BootstrapRenderer()); return $form; }
$this->setView("default"); } else { //Ak je vsetko OK priprav premenne $this->flashRedirect('Pokladnicka:', 'Došlo k chybe. K id neexzistuje položka.', 'danger'); } } else { $this->flashRedirect('Pokladnicka:', 'Došlo k chybe. Neviem id položky.', 'danger'); } } public function renderDefault() { $this->template->pokladnicka = $this->pokladnicka->pokladnicka(); $this->template->h2 = 'Pokladnička:'; $this->template->h4 = $this->h4; }
/** * @param User $user * @param DbTable\Registracia $registracia * @param DbTable\Lang $lang * @param DbTable\Hlavicka $hlavicka * @param DbTable\Dlzka_novinky $dlzka_novinky */ public function __construct(User $user, DbTable\Registracia $registracia, DbTable\Lang $lang, DbTable\Hlavicka $hlavicka, DbTable\Dlzka_novinky $dlzka_novinky) { $this->user = $user; $this->urovneReg = $registracia->urovneReg($this->user->isLoggedIn() ? $this->user->getIdentity()->id_registracia : 0); $this->lang = $lang; $this->hlavickaForm = $hlavicka->hlavickaForm(); $this->dlzkaNovinkyForm = $dlzka_novinky->dlzkaNovinkyForm(); } /** * Edit hlavne menu form component factory. * @param int $uroven Uroven polozky v menu * @param string $uloz Text tlacitka uloz * @param boolean $vlastnik Vlastnictvo editovanej polozky * @param boolean $edit Pre skrytie poloziek pri editacii * @param boolean $opravnenia Opravnenia pre nevlastnikov * @return Form */ public function form($uroven, $uloz, $vlastnik, $edit, $opravnenia) { $form = new Form(); $form->addProtection(); $form->addGroup(); $form->addHidden("id"); $form->addHidden("id_druh"); $form->addHidden("id_user_profiles"); $form->addHidden("spec_nazov"); $form->addHidden("langtxt"); $form->addHidden("id_hlavne_menu_cast"); $form->addHidden("uroven"); $form->addHidden("id_nadradenej"); $form->addHidden("modified"); if (!$edit) { $form->addSelect('id_registracia', 'Povolené prezeranie pre min. úroveň:', $this->urovneReg); } if ($this->user->isInRole("admin")) { $form->addText('nazov_ul_sub', 'Názov alternatívneho vzhľadu:', 20, 20); $form->addText('ikonka', 'Názov class ikonky pre FontAwesome:', 90, 30); if ($uroven) { $form->addHidden('id_hlavicka'); } else { $form->addSelect('id_hlavicka', 'Druh priradenej hlavičky:', $this->hlavickaForm)->addRule(Form::FILLED, 'Je nutné vybrať hlavičku.'); } // $form->addCheckbox('zvyrazni', ' Zvýraznenie položky pri pridaní obsahu'); }
/** * @param Nette\Http\SessionSection $session * @param Nette\ComponentModel\IContainer|null $parent * @param null $name */ public function __construct(\Nette\Http\SessionSection $session, $parent = NULL, $name = NULL) { parent::__construct($parent, $name); $this->session = $session; $this->question = Html::el('p')->addAttributes(array('class' => "{$this->cssClass}--question")); $this->form = new Form($this, 'form'); $this->form->getElementPrototype()->class = "{$this->cssClass}--form"; $this->form->getRenderer()->wrappers['controls']['container'] = NULL; $this->form->addHidden('token'); $this->form->addSubmit('yes', self::$_strings['yes'])->onClick[] = array($this, 'confirmClicked'); $this->form->addSubmit('no', self::$_strings['no'])->onClick[] = array($this, 'cancelClicked'); $this->form['yes']->getControlPrototype()->class = 'btn'; $this->form['no']->getControlPrototype()->class = 'btn'; }
public function create($underSection = false, $underSubSection = false) { $form = new Form(); if ($underSection) { $form->addHidden('underSection', $underSection); } if ($underSubSection) { $form->addHidden('underSubSection', $underSubSection); } $form->addText('name', 'Jméno:')->setRequired('Zadejte jméno')->setAttribute('placeholder', 'Jméno'); $form->addTextArea('description', 'Popis: ')->setAttribute('placeholder', 'Popis'); $add = $underSection ? 'podsekci' : 'sekci'; $form->addSubmit('submit', 'Přidat ' . $add); 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 createComponentLoginForm($name) { $form = new Form(); $form->addHidden('backlink', $this->presenter->getParam('backlink')); $login = $this->getContext()->config->get('user.login'); if ($login === 'username') { $form->addText('username', 'Přihlašovací jméno:')->setRequired('Prosím zadejte Vaše přihlašovací jméno'); } elseif ($login === 'mail') { $form->addText('username', 'E-mail:')->addRule(Form::EMAIL, 'Prosím zadejte Váš e-mail')->setRequired('Prosím zadejte Váš e-mail'); } $form->addPassword('password', 'Heslo:')->setRequired('Prosím zadejte heslo'); //$form->addCheckbox('remember', 'Auto-login in future.'); $form->addSubmit('send', 'Přihlásit se'); $form->onSuccess[] = callback($this, $name . 'Submitted'); $form->onError[] = callback($this, 'ajaxFormErrors'); $request = $this->getContext()->httpRequest; $value = $request->getCookie('vStoreLastLoggedUser'); if ($value !== NULL) { $form['username']->setValue($value); /*$form['password']->setAttribute('class', 'focus'); $form['username']->setAttribute('class', '');*/ } /* else { $form['password']->setAttribute('class', ''); $form['username']->setAttribute('class', 'focus'); }*/ 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 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($role) { $rights = $this->database->table('rights')->fetchPairs('id', 'name'); $form = new Form(); $form->addHidden('id'); $form->addText('username', 'uživatelské jméno: ')->addRule(Form::FILLED, 'Zadejte prosím jméno.'); $form->addText('email', 'email: ')->addRule(Form::FILLED, 'Zadejte prosím email.')->addRule(Form::EMAIL, 'Email by měl mít platný formát'); if (in_array("admin", $role)) { // editace prav jen adminem $form->addSelect('rights_id', 'level práv: ', $rights); } $form->addSubmit('submit', 'uložit'); $form->addProtection('Vypršel časový limit, odešlete formulář znovu'); //bootstrap vzhled $renderer = $form->getRenderer(); $renderer->wrappers['controls']['container'] = NULL; $renderer->wrappers['pair']['container'] = 'div class=form-group'; $renderer->wrappers['pair']['.error'] = 'has-error'; $renderer->wrappers['control']['container'] = ''; $renderer->wrappers['label']['container'] = 'div class="control-label col-sm-5"'; $renderer->wrappers['control']['description'] = 'span class=help-block'; $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block'; $form->getElementPrototype()->class('form-horizontal col-sm-12'); return $form; }
/** @var string */ private $wwwDir; /** * @param DbTable\Dokumenty $dokumenty * @param User $user * @param string $wwwDir */ public function __construct(DbTable\Dokumenty $dokumenty, User $user, $wwwDir = "") { $this->dokumenty = $dokumenty; $this->id_user_profiles = $user->getId(); $this->wwwDir = $wwwDir; } /** * Formular pre pridanie prilohy a editaciu polozky. * @param int $upload_size * @param string $prilohy_adresar * @param array $prilohy_images
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 create(int $id) : Form { $form = new Form(); $form->addHidden('id', $id)->addRule($form::FILLED); $form->addText('value')->addRule($form::FILLED); $form->onSuccess[] = [$this, 'process']; return $form; }
public function createComponentAddToBasket() { $form = new Form(); $form->addHidden('itemId'); $form->addSubmit('ok', 'Vložit do košíku'); $form->onSuccess[] = array($this, 'addToBasketSubmitted'); return $form; }
/** * @return Form */ protected function createComponentForm() { $form = new Form(); $form->addProtection(); $form->addHidden('data')->setRequired(); $form->onSuccess[] = [$this, 'formSuccess']; return $form; }
public function createComponentCategoryForm() { $form = new Form(); $form->addText("title", "Title: ")->setRequired(); $form->addSubmit('ok', 'Save'); $form->addHidden('category_id'); $form->onSuccess[] = $this->categoryFormSubmitted; return $form; }