Example #1
0
 /**
  * @param Form $form
  */
 public function check($form)
 {
     if (!$form->getMapper() instanceof EntityMapper) {
         throw new \Nette\InvalidArgumentException("Form mapper must be instanceof 'EntityMapper'. '" . get_class($form->getMapper()) . "' is given.");
     }
     if (!$form->getData() instanceof \DoctrineModule\Entities\IEntity) {
         throw new \Nette\InvalidArgumentException("Form data must be instanceof 'IEntity'. '" . get_class($form->getData()) . "' is given.");
     }
 }
Example #2
0
 public function configure(Form $form)
 {
     $form->addGroup('Nastavení API');
     $form->addText('apiUrl', 'URL pro api');
     if ($form->getData()->getApiUrl()) {
         $apiClient = $this->apiClientFactory->create($form->getData()->getApiUrl());
         $data = $apiClient->callApi('/bodies.json');
         $items = array();
         foreach ($data['bodies'] as $organ) {
             $items[$organ['id']] = $organ['name'];
         }
         $form->addSelect('section', 'Sekce', $items);
     }
     $form->setCurrentGroup();
     $form->addSaveButton('Save');
 }