src/Aqarmap/Bundle/DiscussionBundle/Form/DiscussionSearchType.php line 11

Open in your IDE?
  1. <?php
  2. namespace Aqarmap\Bundle\DiscussionBundle\Form;
  3. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. class DiscussionSearchType extends AbstractType
  9. {
  10.     public function buildForm(FormBuilderInterface $builder, array $options): void
  11.     {
  12.         $builder
  13.             ->add('location'ChoiceType::class, [
  14.                 'required' => true,
  15.                 'placeholder' => 'layout.locations',
  16.                 'choices' => $options['selectedLocation'],
  17.                 'data' => $options['selectedLocationId'],
  18.             ])
  19.             ->add('category'EntityType::class, [
  20.                 'required' => true,
  21.                 'class' => 'AqarmapDiscussionBundle:Category',
  22.                 'placeholder' => 'neighborhoods.discussion.placeholder.all_categories',
  23.             ])
  24.         ;
  25.     }
  26.     public function configureOptions(OptionsResolver $resolver): void
  27.     {
  28.         $resolver->setDefaults([
  29.             'data_class' => 'Aqarmap\Bundle\DiscussionBundle\Entity\Discussion',
  30.             'flatLocations' => [],
  31.             'selectedLocation' => [],
  32.             'selectedLocationId' => null,
  33.         ]);
  34.     }
  35. }