public function createComponentContentForm() { $form = new BaseForm(); $form->addHidden("id"); $form->addHidden("userId")->setDefaultValue($this->getUser()->id); $form->addText("sectionId", "Sekce")->setDefaultValue($this->sectionId); $form->addText("title", "Název")->setRequired(); $form->addText("author", "Autor"); $form->addText("pageTitle", "Název stránky"); $form->addText("anotation", "Krátký text"); $form->addTextArea("text", "Dlouhý text")->setAttribute('class', 'wysiwyg'); $form->addDateTimePicker("activeFrom", "Aktivní od:")->setDefaultValue(date('Y-m-d G:i', time())); $form->addDateTimePicker("activeUntil", "Aktivní do:"); $form->addCheckbox("isDraft", "Draft")->setDefaultValue(1); $form->addCheckbox("isNews", "Novinka"); $form->addCheckbox("isSticky", "Sticky bit"); if ($this->user->getIdentity()->roleId == 1 || $this->user->getIdentity()->roleId == 2) { $form->addText("routeUrl", "Routa"); } $form->addSubmit("save", "Uložit"); $form->onSuccess[] = $this->contentFormSucceeded; return $form; }
public function createComponentForm() { $form = new BaseForm(); $form->getElementPrototype()->addAttributes(['class' => 'program-edit-form', 'enctype' => 'multipart/form-data', 'id' => null]); $form->addText('contentTitle', 'Název')->setRequired(); $form->addSelect('typeId', 'Druh programu', $this->programModel->getTypesPairs()); $form->addSelect('genreId', 'Sekce', $this->programModel->getGenresPairs()); $form->addSelect('roomId', 'Místnost', $this->programModel->getRoomsPairs('1,2,3,4,5')); $form->addText('author', 'Autor'); $form->addCheckbox('isSticky', 'Zobrazit na Homepage (pokud má obrázek)')->setDefaultValue(FALSE); $form->addTextArea('contentText', 'Anotace')->setAttribute('class', 'wysiwyg'); //anotace $timeFromInput = $form->addText('timeFrom', 'Začátek'); $timeFromInput->getControlPrototype()->addAttributes(['class' => 'js-period-start', 'data' => ['timeFrom' => $this->timeFrom->format('Y-m-d H:i:s')]]); $timeFromInput->setDefaultValue($this->timeFrom->format('Y-m-d H:i:s')); $timeToInput = $form->addText('timeTo', 'Konec'); $timeToInput->getControlPrototype()->addAttributes(['class' => 'js-period-end', 'data' => ['timeTo' => $this->timeTo->format('Y-m-d H:i:s')]]); $timeToInput->setDefaultValue($this->timeTo->format('Y-m-d H:i:s')); $form->addCheckbox('isDraft', 'Draft')->setDefaultValue(TRUE); $form->addSubmit('submit', 'Odeslat')->getControlPrototype()->addAttributes(['class' => 'btn']); $form->addHidden('id', NULL); $form->getElementPrototype()->class = $form->getElementPrototype()->class . ' js-program-edit-form'; if ($this->programId) { $formDefaults = $this->getFormDefaults(); $form->setDefaults($formDefaults); $form->getComponent('id')->setValue($this->programId); } $form->onValidate[] = callback($this, 'formValidate'); $form->onSuccess[] = callback($this, 'formSuccessful'); return $form; }