src/Form/Backend/AdvancedSearchType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form\Backend;
  3. use App\Model\Search\AdvancedSearch;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\Form\FormEvent;
  8. use Symfony\Component\Form\FormEvents;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class AdvancedSearchType extends AbstractType
  11. {
  12.     /**
  13.      * @param FormBuilderInterface $builder
  14.      * @param array $options
  15.      */
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('searchCriteria'CollectionType::class, [
  20.                 'entry_type' => SearchCriteriumType::class,
  21.                 'entry_options'=> [
  22.                     'parameters' => $options['parameters'],
  23.                     'entityName' => $options['entityName']
  24.                 ],
  25.                 'label' => false,
  26.                 'allow_add' => true,
  27.                 'allow_delete' => true,
  28.             ])
  29.         ;
  30.     }
  31.     /**
  32.      * @param OptionsResolver $resolver
  33.      */
  34.     public function configureOptions(OptionsResolver $resolver): void
  35.     {
  36.         $resolver->setDefaults([
  37.             'data_class' => AdvancedSearch::class,
  38.             'entityName'=> null,
  39.             'parameters' => null,
  40.         ]);
  41.     }
  42. }