예제 #1
0
 /**
  * Edit page content
  */
 function createComponentEditForm()
 {
     $pages = $this->database->table("pages")->get($this->presenter->getParameter("id"));
     $form = new \Nette\Forms\BootstrapPHForm();
     $form->setTranslator($this->presenter->translator);
     $form->getElementPrototype()->class = "form-horizontal";
     $form->getElementPrototype()->role = 'form';
     $form->getElementPrototype()->autocomplete = 'off';
     $l = $this->presenter->getParameter("l");
     if ($this->presenter->template->member->users_roles->pages_document) {
         $enabled = false;
     } else {
         $enabled = true;
     }
     $form->addHidden("id");
     $form->addHidden("l");
     $form->addHidden("docs_id");
     $form->addTextArea("document")->setAttribute("class", "form-control")->setDisabled($enabled);
     if ($l == '') {
         $form->setDefaults(array("id" => $pages->id, "document" => $pages->document));
     } else {
         $form->setDefaults(array("id" => $pages->id, "l" => $l, "document" => $pages->{'document_' . $l}));
     }
     $form->addHidden("slug_old");
     $form->addGroup("");
     $form->addCheckbox("public", "dictionary.main.PublishedForm");
     $form->addText("date_published", "Datum zveřejnění")->setAttribute("class", "datetimepicker");
     $form->addText("title", "dictionary.main.Title");
     $form->addText("slug", "dictionary.main.Slug");
     $form->addText("document2");
     $form->addSelect("parent");
     $form->addSelect("template");
     $form->addGroup("dictionary.main.MetaTags");
     $form->addTextArea("metadesc", "dictionary.main.MetaDesc")->setAttribute("class", "form-control");
     $form->addTextArea("metakeys", "dictionary.main.MetaKeys")->setAttribute("class", "form-control");
     if ($l == '') {
         $form->setDefaults(array("id" => $pages->id, "slug" => $pages->slug, "slug_old" => $pages->slug, "metadesc" => $pages->metadesc, "metakeys" => $pages->metakeys, "title" => $pages->title, "public" => $pages->public, "date_published" => $pages->date_published));
     } else {
         $form->setDefaults(array("id" => $pages->id, "l" => $l, "slug" => $pages->{'slug_' . $l}, "slug_old" => $pages->{'slug_' . $l}, "metadesc" => $pages->{'metadesc_' . $l}, "metakeys" => $pages->{'metakeys_' . $l}, "title" => $pages->{'title_' . $l}, "public" => $pages->public, "date_published" => $pages->date_published));
     }
     $form->onSuccess[] = $this->editFormSucceeded;
     $form->onValidate[] = $this->permissionValidated;
     $form->addSubmit("submit", "dictionary.main.Save")->setHtmlId('formxins');
     return $form;
 }