Example #1
0
 protected function createComponentGenreEditor()
 {
     $form = new Form();
     $form->addText('name', 'Žánr')->setRequired("Zadejte název žánru");
     $form->addText('popis', 'Krátký popis');
     $form->addHidden('id');
     $form->addSubmit('send', 'Přidat');
     $form->onSuccess[] = function (Form $frm) {
         $values = $frm->values;
         if ($values->id) {
             $this->zanry->find($values->id)->update($values);
             $this->logger->log('Genre', 'edit', "%user% upravila(a) žánr {$values->name}");
             $msg = $this->flashMessage("Žánr '{$values->name}' editován.", 'success');
             $msg->title = 'A je tam!';
             $msg->icon = 'check';
         } else {
             $this->zanry->add($values);
             $this->logger->log('Genre', 'add', "%user% přidala(a) žánr {$values->name}");
             $msg = $this->flashMessage("Žánr '{$values->name}' přidán.", 'success');
             $msg->title = 'A je tam!';
             $msg->icon = 'check';
         }
         $this->redirect('this');
     };
     return $form;
 }