Exemplo n.º 1
0
 /**
  * @param FormInterface $form
  * @param string|null   $data
  */
 private function buildForm(FormInterface $form, $data)
 {
     $form->remove('value');
     if ($data === null || in_array($data, ResourceType::getSimpleTypes(), true)) {
         $filter = $form->getConfig()->getOption('filter');
         if ($filter->hasOption('form')) {
             $resourceForm = $filter->getOption('form');
         } else {
             $resource = $filter->hasOption('resource') ? $filter->getOption('resource') : $filter->getName();
             $resourceForm = $this->resourceRegistry[$resource]->getChoiceForm();
         }
         $form->add('value', $resourceForm);
     }
 }
Exemplo n.º 2
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add($builder->create('type', ChoiceType::class, ['choices' => array_combine(array_map(function ($choice) use($options) {
         return $options['label_prefix'] . '.type.' . $choice;
     }, $choices = ResourceType::getTypes()), $choices), 'choices_as_values' => true, 'xml_http_request_trigger' => true])->addEventSubscriber($this->resourceFilterSubscriber));
 }
Exemplo n.º 3
0
 public function testEmptyTypes()
 {
     $this->assertSame([ResourceType::TYPE_EMPTY, ResourceType::TYPE_NOT_EMPTY], ResourceType::getEmptyTypes());
 }