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; }