/** * Edit contact */ function createComponentEditForm() { $this->template->id = $this->presenter->getParameter('id'); $categories = new \App\Model\Category($this->database); $cats = $categories->getSubIds(2); $groups = $this->database->table("categories")->where("id", $cats)->fetchPairs("id", "title"); $form = new \Nette\Forms\BootstrapUIForm(); $form->setTranslator($this->presenter->translator); $form->getElementPrototype()->class = "form-horizontal"; $form->getElementPrototype()->role = 'form'; $form->getElementPrototype()->autocomplete = 'off'; $form->addGroup(''); $form->addHidden('contact_id'); $form->addHidden('pages_id'); $form->addText("name", "dictionary.main.Name")->setAttribute("placeholder", "dictionary.main.Name"); $form->addText("company", "dictionary.main.Company")->setAttribute("placeholder", "dictionary.main.Company"); $form->addRadioList("type", "Osoba nebo organizace", array(0 => " osoby", 1 => " organizace")); $form->addText("post", "dictionary.main.Post")->setAttribute("placeholder", "dictionary.main.Post")->setOption("description", 1); $form->addText("email", "E-mail")->setAttribute("placeholder", "dictionary.main.Email")->setAttribute("class", "form-control"); $form->addText("phone", "dictionary.main.Phone")->setAttribute("placeholder", "dictionary.main.Phone")->setAttribute("class", "form-control"); $form->addSelect("categories_id", "dictionary.main.Category", $groups)->setAttribute("class", "form-control"); $form->addGroup('dictionary.main.Address'); $form->addText("street", "Ulice")->setAttribute("placeholder", "dictionary.main.Street")->setOption("description", 1); $form->addText("zip", "dictionary.main.ZIP")->setAttribute("placeholder", "dictionary.main.ZIP")->setOption("description", 1); $form->addText("city", "Město")->setAttribute("placeholder", "Město")->setOption("description", 1); $form->addGroup('Firemní údaje'); $form->addText("vatin", "IČ")->setAttribute("placeholder", "dictionary.main.VatIn")->setOption("description", 1); $form->addText("vatid", "DIČ")->setAttribute("placeholder", "dictionary.main.VatId")->setHtmlId("kurzy_ico")->setOption("description", 1); $form->addText("banking_account", "Bankovní účet")->setAttribute("placeholder", "Bankovní účet")->setOption("description", 1); $form->addText("dateofbirth", "Datum narození")->setAttribute("placeholder", "Datum narození"); $form->addGroup('Ostatní'); $form->addTextArea("notes", "dictionary.main.Notes")->setAttribute("class", "form-control"); $page = $this->database->table("pages")->get($this->presenter->getParameter("id")); $contact = $this->database->table("contacts")->where("pages_id", $this->presenter->getParameter("id"))->fetch(); $arr = array("contact_id" => $contact->id, "pages_id" => $page->id, "name" => $contact->name, "company" => $contact->company, "post" => $contact->post, "type" => $contact->type, "email" => $contact->email, "phone" => $contact->phone, "categories_id" => $contact->categories_id, "street" => $contact->street, "zip" => $contact->zip, "city" => $contact->city, "banking_account" => $contact->banking_account, "vatin" => $contact->vatin, "vatid" => $contact->vatid, "notes" => $contact->notes, "dateofbirth" => $contact->date_of_birth); $form->setDefaults($arr); $form->addSubmit("submitm", "dictionary.main.Save")->setAttribute("class", "btn btn-success"); $form->onSuccess[] = $this->editFormSucceeded; $form->onValidate[] = $this->editFormValidated; return $form; }
public function createComponentSignUpForm() { $form = new \Nette\Forms\BootstrapUIForm(); $form->setTranslator($this->presenter->translator); $form->getElementPrototype()->class = "form-horizontal"; $form->getElementPrototype()->role = 'form'; $form->getElementPrototype()->autocomplete = 'off'; $form->addGroup("Uživatelské informace"); $form->addText("email", "E-mail")->addRule(\Nette\Forms\Form::EMAIL, 'Zadejte platný email.')->setRequired('Vložte e-mail.'); $form->addText("username", "Uživatelské jméno")->setOption('description', (string) "Povoleny jsou pouze znaky a-z, 0-9 (pouze malá písmena)")->setRequired('Zvolte si uživatelské jméno')->addRule(\Nette\Forms\Form::PATTERN, 'Uživatelské jméno může obsahovat pouze znaky a-z, 0-9 (pouze malá písmena)', '[a-z0-9-]+')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zvolte uživatelské jméno s alespoň %d znaky', 5)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zvolte uživatelské jméno s nejvýše %d znaky', 40); if ($this->presenter->template->settings['members:groups:enabled']) { $groups = $this->database->table("categories")->where("parent_id", $this->presenter->template->settings['members:group:categoryId'])->fetchPairs("id", "title"); $form->addSelect("group", "Skupina", $groups)->setAttribute("class", "form-control"); } $form->addPassword("pwd", "dictionary.main.Password")->setOption('description', (string) "6 - 40 znaků")->setRequired('Zvolte si heslo')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zvolte heslo s alespoň %d znaky', 6)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zvolte heslo s nejvýše %d znaky', 40); $form->addPassword("pwd2", "Zopakovat heslo")->setRequired('Zadejte prosím heslo ještě jednou pro kontrolu')->addRule(\Nette\Forms\Form::EQUAL, 'Hesla se neshodují', $form['pwd']); if ($this->presenter->template->settings['members:signup:contactEnabled']) { $form->addGroup("Kontaktní údaje"); $form->addText("name", "Jméno a příjmení")->setRequired('Zadejte jméno')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zadejte jméno', 3)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zadejte jméno', 200); $form->addText("street", "dictionary.main.Street")->setRequired('Zadejte ulici')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zadejte ulici', 3)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zadejte ulici', 200)->setAttribute("class", "smartform-street-and-number"); $form->addText("zip", "PSČ")->setRequired('Zadejte PSČ')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zadejte PSČ', 3)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zadejte PSČ', 20)->setAttribute("class", "smartform-city"); $form->addText("city", "Město")->setRequired('Zadejte město')->addRule(\Nette\Forms\Form::MIN_LENGTH, 'Zadejte město', 1)->addRule(\Nette\Forms\Form::MAX_LENGTH, 'Zadejte město', 80)->setAttribute("class", "smartform-zip"); } if ($this->presenter->template->settings['members:signup:contactEnabled']) { $form->addGroup("Firemní informace"); $form->addText("company", "dictionary.main.Company"); $form->addText("vatin", "dictionary.main.VatIn"); $form->addText("vatid", "dictionary.main.VatId"); } $form->addCheckbox("newsletter", " " . "Chci odebírat zprávy?")->setDefaultValue(TRUE); $form->addCheckbox("confirmation", " " . "Souhlasím s podmínkami")->setRequired('Pro pokračování zaškrtněte Souhlasím s podmínkami'); $form->setDefaults(array("username" => $this->presenter->getParameter("user"), "email" => $this->presenter->getParameter("email"), "newsletter" => $this->presenter->getParameter("newsletter"), "name" => $this->presenter->getParameter("name"), "street" => $this->presenter->getParameter("street"), "city" => $this->presenter->getParameter("city"), "zip" => $this->presenter->getParameter("zip"))); $form->addSubmit("submit", "Registrovat se")->setAttribute("class", "btn-lg btn-cart-in"); $form->setDefaults(array("email" => $this->getParameter("email"), "username" => $this->getParameter("username"), "newsletter" => $this->getParameter("newsletter"))); $form->onSuccess[] = $this->signUpFormSucceeded; $form->onValidate[] = $this->signUpFormValidated; return $form; }
protected function createComponentInsertForm() { $form = new \Nette\Forms\BootstrapUIForm(); $form->setTranslator($this->presenter->translator); $form->getElementPrototype()->class = "form-horizontal"; $form->getElementPrototype()->role = 'form'; $form->getElementPrototype()->autocomplete = 'off'; $languages = $this->database->table("languages")->where(array("default" => null, "used" => 1)); if ($languages->count() > 1) { $form->addGroup("čeština"); } $form->addHidden("parent"); $form->addText('title', 'dictionary.main.Title')->setAttribute("class", "form-control"); $form->addText('url', 'dictionary.main.URL')->setAttribute("class", "form-control"); foreach ($languages as $item) { $form->addGroup($item->title); $form->addText("title_" . $item->code, 'dictionary.main.Title')->setAttribute("class", "form-control"); $form->addText("url_" . $item->code, 'dictionary.main.URL')->setAttribute("class", "form-control"); } $form->addSubmit('submitm', 'dictionary.main.Insert')->setAttribute("class", "btn btn-primary"); $form->onSuccess[] = $this->insertFormSucceeded; $form->onValidate[] = $this->validateFormSucceeded; return $form; }
/** * Edit your profile */ function createComponentEditForm() { $form = new \Nette\Forms\BootstrapUIForm(); $form->setTranslator($this->presenter->translator); $form->getElementPrototype()->class = "form-horizontal"; $form->getElementPrototype()->role = 'form'; $form->getElementPrototype()->autocomplete = 'off'; $form->addGroup("Osobní údaje"); $form->addText("username", "Uživatel")->setAttribute("style", "border: 0; font-size: 1.5em;")->setDisabled(); $form->addRadioList('sex', 'Pohlaví', array(1 => " " . 'žena', 2 => " " . 'muž'))->setAttribute("class", "checkboxlistChoose"); $form->setDefaults(array("username" => $this->presenter->template->member->username, "sex" => $this->presenter->template->member->sex)); $form->addSubmit("submit", "dictionary.main.Save"); $form->onSuccess[] = $this->editFormSucceeded; return $form; }
/** * Edit by user */ function createComponentEditForm() { $form = new \Nette\Forms\BootstrapUIForm(); $form->setTranslator($this->presenter->translator); $form->getElementPrototype()->class = "form-horizontal"; $form->getElementPrototype()->role = 'form'; $form->getElementPrototype()->autocomplete = 'off'; $members = $this->database->table("users")->get($this->presenter->user->getId()); $cols = array("username" => $members->username, "email" => $members->email, "name" => $members->name); $form->addGroup("Základní nastavení"); $form->addText("name", "Name"); $form->setDefaults(array("name" => $cols["name"])); $form->addSubmit("submit", "dictionary.main.Save"); $form->onSuccess[] = array($this, 'editFormSucceeded'); return $form; }