src/Form/FrontFormBusquedaCursoType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Localidad;
  4. use Doctrine\ORM\EntityRepository;
  5. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  6. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  7. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. class FrontFormBusquedaCursoType extends AbstractType
  14. {
  15. public function buildForm(FormBuilderInterface $builder, array $options): void
  16. {
  17. $builder
  18. ->add('idProveedor', HiddenType::class, [
  19. 'data' => '',
  20. ])
  21. ->add('nombre', TextType::class, [
  22. 'label' => 'Nombre',
  23. 'attr' => [
  24. 'class' => 'manual-placeholder',
  25. 'placeholder' => 'Nombre curso...'
  26. ],
  27. 'required' => false
  28. ])
  29. // ->add('ordenarPor', ChoiceType::class, [
  30. // 'placeholder' => false,
  31. // 'label' => false,
  32. // 'attr' => [
  33. // 'class' => 'manual-placeholder bsselectpicker',
  34. // ],
  35. // 'required' => false,
  36. // 'choices' => [
  37. // 'Valoración más alta' => 'valoracion',
  38. // 'Alfabético ascendente' => 'asc',
  39. // 'Alfabético descendente' => 'desc',
  40. // 'Más reciente' => 'masReciente',
  41. // 'Menos reciente' => 'menosReciente'
  42. // ],
  43. // 'data' => 'masReciente'
  44. // ])
  45. ->add('localidad', EntityType::class, [
  46. 'placeholder' => 'Localidad',
  47. 'label' => 'Localidad',
  48. 'attr' => [
  49. 'class' => 'manual-placeholder bsselectpicker'
  50. ],
  51. 'required' => false,
  52. 'choice_label' => 'nombre',
  53. 'class' => Localidad::class,
  54. 'choice_attr' => fn(Localidad $object): array => [
  55. 'data-slug' => $object->getSlug(),
  56. ],
  57. 'query_builder' => fn(EntityRepository $repository) => $repository
  58. ->createQueryBuilder('l')
  59. ->andWhere('l.visible = true AND l.borrado = false')
  60. ->orderBy('l.nombre', 'ASC')
  61. ])
  62. ->add('captcha', Recaptcha3Type::class, [
  63. 'constraints' => [
  64. new Recaptcha3()
  65. ],
  66. 'locale' => 'es'
  67. ])
  68. ;
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function configureOptions(OptionsResolver $resolver): void
  74. {
  75. $resolver->setDefaults([
  76. 'translation_domain' => 'app',
  77. 'data_class' => null,
  78. 'globales' => null
  79. ]);
  80. }
  81. /**
  82. * {@inheritdoc}
  83. */
  84. public function getBlockPrefix(): string
  85. {
  86. return 'front_busqueda_curso';
  87. }
  88. }