src/Form/SearchForm.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Data\SearchData;
  4. use App\Entity\Seller;
  5. use App\Entity\Category;
  6. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. class SearchForm extends AbstractType
  14. {
  15.     public function buildForm(FormBuilderInterface $builder, array $options)
  16.     {
  17.         $builder
  18.             ->add('q'TextType::class, [
  19.                 'label' => false,
  20.                 'required' => false,
  21.                 'attr' => [
  22.                     'placeholder' => 'What are you Looking for ?',
  23.                 ],
  24.             ])
  25.             // ->add('categories', EntityType::class, [
  26.             //     'label' => false,
  27.             //     'required' => false,
  28.             //     'class' => Category::class,
  29.             //     'choice_label' => 'Name',
  30.             //     'expanded' => true,
  31.             //     'multiple' => true
  32.             // ])
  33.             ->add('categories'EntityType::class, array(
  34.                 'class' => Category::class,
  35.                 'choice_label' => 'name',
  36.                 'label' => false,
  37.                 'placeholder' => 'All categories',
  38.                 'required' => false,
  39.                 'choice_translation_domain' => 'messages',
  40.             ));
  41.     }
  42.     public function configureOptions(OptionsResolver $resolver)
  43.     {
  44.         $resolver->setDefaults([
  45.             'data_class' => SearchData::class,
  46.             'method' => 'GET',
  47.             'csrf_protection' => false,
  48.         ]);
  49.     }
  50.     public function getBlockPrefix()
  51.     {
  52.         return '';
  53.     }
  54. }