Пример #1
0
 /**
  * @return Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->addUpload('file', 'Súbor:');
     $form->addSubmit('upload', 'Nahrať');
     return $form;
 }
Пример #2
0
 /**
  * @param Form $form
  */
 private function setTranslations(Form $form)
 {
     if ($this->entity !== NULL && !$this->entity->isDetached()) {
         if ($translationsContainer = $form->getComponent('translations', false)) {
             $translationsContainer->setDefaults($this->repository->getTranslations($this->entity));
         }
     }
 }
Пример #3
0
 /**
  * @param Form $form
  */
 private function setData(Form $form)
 {
     if (!$this->entity->isDetached()) {
         foreach ($form->getComponents() as $control) {
             $name = $control->getName();
             if (isset($this->entity->{$name})) {
                 if ($control instanceof Container) {
                     $control->setDefaults($this->entity->{$name});
                 } else {
                     $control->setDefaultValue($this->entity->{$name});
                 }
             }
         }
     }
 }
Пример #4
0
 public function processForm(Form $form)
 {
     if ($form['filter']['filter']->isSubmittedBy()) {
         $filter = $form->values->filter;
         foreach ($filter as $column => $value) {
             if (empty($value)) {
                 unset($filter[$column]);
             }
         }
         $this->filter = $filter;
     } else {
         $values = ArrayHash::from($form->getHttpData());
         if (!isset($values->item)) {
             $this->flashMessage('Nezvolili ste záznamy', 'alert-error');
             return false;
         }
         $items = $values->item;
         $action = $form->submitted->name;
         if (!isset($this->actions[$action])) {
             throw new InvalidArgumentException("Action '{$action}' not found");
         }
         if (count($items) > 0) {
             $data = $this->getRows();
             $rows = [];
             foreach ($items as $item => $checked) {
                 if ($item == 'all') {
                     continue;
                 }
                 if ($checked !== 'on') {
                     continue;
                 }
                 $rows[] = $data[$item];
             }
             $this->actions[$action]->invoke($rows);
             $this->flashMessage('Akcia bola vykonaná.', 'alert-success');
             $this->invalidateControl();
         }
     }
 }