src/Form/SearchFormType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Ville;
  4. use App\Data\SearchData;
  5. use App\Entity\Categorie;
  6. use App\Entity\SousCategorie;
  7. use Symfony\Component\Form\AbstractType;
  8. use App\Repository\SousCategorieRepository;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. class SearchFormType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('q'TextType::class, [
  20.                 'label' => false,
  21.                 'required' => false,
  22.                 'attr' => [
  23.                     'placeholder' => 'Rechercher'
  24.                 ]
  25.             ])
  26.             ->add('categories'EntityType::class, [
  27.                 'label' => false,
  28.                 'required' => false,
  29.                 'class' => SousCategorie::class,
  30.                 'query_builder' => function (SousCategorieRepository $f) {
  31.                     return $f->createQueryBuilder('f')
  32.                         ->orderBy('f.title''ASC');
  33.                 },
  34.                 'expanded' => true,
  35.                 'multiple' => true
  36.             ])
  37.             ->add('type'ChoiceType::class, [
  38.                 'required' => false,
  39.                 'choices' => [
  40.                     'CDI' => 'cdi',
  41.                     'CDD' => 'cdd',
  42.                     'INTERIM' => 'interim',
  43.                     'FREELANCE' => 'freelance'
  44.                 ],
  45.                 'expanded' => true,
  46.                 'placeholder' => Null,
  47.             ])
  48.             ->add('ville'TextType::class, [
  49.                 'label' => false,
  50.                 'required' => false,
  51.                 'attr' => [
  52.                     'placeholder' => 'ville ...'
  53.                 ]
  54.             ]);
  55.     }
  56.     public function configureOptions(OptionsResolver $resolver)
  57.     {
  58.         $resolver->setDefaults([
  59.             'data_class' => SearchData::class,
  60.             'method' => 'GET',
  61.             'csrf_protection' => false
  62.         ]);
  63.     }
  64.     public function getBlockPrefix()
  65.     {
  66.         return '';
  67.     }
  68. }