src/Form/SearchForm.php line 13

  1. <?php
  2. namespace App\Form;
  3. use App\Data\SearchData;
  4. use App\Entity\Category;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  8. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. class SearchForm extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options)
  14.     {
  15.         $builder
  16.             ->add('q'TextType::class, [
  17.                 'label' => false,
  18.                 'required' => false,
  19.                 'attr' => [
  20.                     'placeholder' => 'Rechercher un commerce'
  21.                 ]
  22.             ])
  23.             ->add('Category'EntityType::class, [
  24.                 'label' => false,
  25.                 'required' => false,
  26.                 'class' => Category::class,
  27.                 'expanded' => true,
  28.                 'multiple' => true
  29.              ])
  30.              ->add('verified'CheckboxType::class, [
  31.                 'label' => 'Vérifié par Best of Sarlat',
  32.                 'required' => false
  33.              ])
  34.                 
  35.             ;
  36.     }
  37.     public function configureOptions(OptionsResolver $resolver)
  38.     {
  39.         $resolver->setDefaults([
  40.             'data_class' => SearchData::class,
  41.             // 'method' => 'GET',
  42.             'csrf_protection' => false
  43.         ]);
  44.     }
  45.     public function getBlockPrefix()
  46.     {
  47.         return '';
  48.     }
  49. }