Exemplo n.º 1
0
 private function create()
 {
     $form = new Form();
     $form->addText('title', 'Titulek')->setRequired('Zadejte titulek')->setAttribute('placeholder', 'Zadejte titulek');
     if ($this->user->isAllowed(self::RES, 'moderate')) {
         $users = $this->userManager->getUserList();
         $form->addSelect('byUser', 'Za uživatele', ['0' => 'Neregistrovaný'] + $users['deleted'] + $users['allowed'])->setValue($this->user->id);
         $form->addText('byUnregUser', 'Za neregistrovaného uživatele');
     }
     $form->addTextArea('description', 'Popis')->setRequired('Zadejte popis');
     $form->addTextArea('text', 'Článek')->setRequired('Zadejte článek');
     $form->addText('keyWords', 'Klíčová slova');
     $form->addCheckbox('commentsAllow', 'Povolit komentáře');
     $form->addCheckbox('voteAllow', 'Povolit hlasování');
     $form->addUpload('photo', 'Náhledová fotka');
     if ($this->setSection) {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setValue($this->setSection);
         if ($this->setSubsection) {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setValue($this->setSubsection);
             if ($this->setSerial) {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setValue($this->setSerial);
             } else {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setPrompt('Vyberte');
             }
         } else {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setPrompt('Vyberte podsekci');
             $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte podsekci');
         }
     } else {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSubSection', 'Podsekce')->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte hlavní sekci');
     }
     if ($this->user->isAllowed('Section', 'moderate')) {
     }
     if ($this->user->isAllowed(self::RES, 'publish')) {
         $form->addCheckbox('published', 'Publikovaný ihned');
     }
     $form->addSubmit('submitArticle', 'Odeslat')->setValidationScope(false);
     return $form;
 }