src/Form/SearchOffreType.php line 39

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