/** * Edit user data */ 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'; $user = $this->database->table("users")->get($this->presenter->getParameter("id")); $form->addHidden('id'); $form->addRadioList("sex", "Pohlaví", array(1 => ' žena', 2 => ' muž')); $form->addRadioList("newsletter", "Odebírat newsletter", array(1 => ' ano', 2 => ' ne')); $form->addRadioList("state", "Stav účtu", array(1 => ' povolen', 2 => ' blokován')); $roles = $this->database->table("users_roles")->fetchPairs("id", "title"); if ($this->template->member->username == 'admin') { $form->addSelect("role", "Role", $roles)->setAttribute("class", "form-control"); } 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"); } $arr = array("id" => $this->presenter->getParameter("id"), "sex" => $user->sex, "newsletter" => $user->newsletter, "state" => $user->state, "role" => $user->role, "group" => $user->categories_id); $form->setDefaults(array_filter($arr)); $form->addSubmit('submitm', 'dictionary.main.Save')->setAttribute("class", "btn btn-primary"); $form->onSuccess[] = $this->editFormSucceeded; $form->onValidate[] = $this->editFormValidated; 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 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; }