src/Form/SearchType.php line 14

Open in your IDE?
  1. <?php 
  2. namespace App\Form;
  3. use App\Classe\Search;
  4. use App\Entity\Familly;
  5. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class SearchType extends AbstractType
  12. {
  13. public function buildForm(FormBuilderInterface $builder, array $options)
  14. {
  15.     $builder
  16.         ->add('string'TextType::class, [
  17.             'label' => false,
  18.             'required' => false,
  19.             'attr' => [
  20.             'placefolder' => 'Votre recherche ...',
  21.             'class' => 'form-control-sm'
  22.         ]
  23.         ])
  24.         ->add('categories'EntityType::class, [
  25.             'label' => false,
  26.             'required' => false,
  27.             'class' => Familly::class,
  28.             'multiple' => true,
  29.             'expanded' => true
  30.         ])
  31.         
  32.         ->add('submit'SubmitType::class,
  33.         [
  34.         'label' => 'Filtrer',
  35.         'attr' =>[
  36.             'class' =>'btn-block btn-info'
  37.         ]
  38.         ])
  39.         ;
  40. }
  41.     public function configureOptions(OptionsResolver $resolver)
  42.     {
  43.         $resolver->setDefaults([
  44.             'data_class' => Search:: class,
  45.             'method'=>'GET',
  46.             'crsf_protection'=>false,
  47.         ]);
  48.     }
  49.     public function getBlockPrefix()
  50.     {
  51.         return '';
  52.     }
  53. }