src/Form/FrontFormBusquedaJornadaCursoType.php line 55

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 FrontFormBusquedaJornadaCursoType extends AbstractType
  14. {
  15. public function buildForm(FormBuilderInterface $builder, array $options): void
  16. {
  17. $builder
  18. ->add('nombre', TextType::class, [
  19. 'label' => 'Nombre',
  20. 'attr' => [
  21. 'class' => 'manual-placeholder',
  22. 'placeholder' => 'Nombre jornada...'
  23. ],
  24. 'required' => false
  25. ])
  26. // ->add('ordenarPor', ChoiceType::class, [
  27. // 'placeholder' => false,
  28. // 'label' => false,
  29. // 'attr' => [
  30. // 'class' => 'manual-placeholder bsselectpicker',
  31. // ],
  32. // 'required' => false,
  33. // 'choices' => [
  34. // 'Valoración más alta' => 'valoracion',
  35. // 'Alfabético ascendente' => 'asc',
  36. // 'Alfabético descendente' => 'desc',
  37. // 'Más reciente' => 'masReciente',
  38. // 'Menos reciente' => 'menosReciente'
  39. // ],
  40. // 'data' => 'masReciente'
  41. // ])
  42. ->add('localidad', EntityType::class, [
  43. 'placeholder' => 'Localidad',
  44. 'label' => 'Localidad',
  45. 'attr' => [
  46. 'class' => 'manual-placeholder bsselectpicker'
  47. ],
  48. 'required' => false,
  49. 'choice_label' => 'nombre',
  50. 'class' => Localidad::class,
  51. 'choice_attr' => fn(Localidad $object): array => [
  52. 'data-slug' => $object->getSlug(),
  53. ],
  54. 'query_builder' => fn(EntityRepository $repository) => $repository
  55. ->createQueryBuilder('l')
  56. ->andWhere('l.visible = true AND l.borrado = false')
  57. ->orderBy('l.nombre', 'ASC')
  58. ])
  59. ->add('captcha', Recaptcha3Type::class, [
  60. 'constraints' => [
  61. new Recaptcha3()
  62. ],
  63. 'locale' => 'es'
  64. ])
  65. ;
  66. }
  67. /**
  68. * {@inheritdoc}
  69. */
  70. public function configureOptions(OptionsResolver $resolver): void
  71. {
  72. $resolver->setDefaults([
  73. 'translation_domain' => 'app',
  74. 'data_class' => null,
  75. 'globales' => null
  76. ]);
  77. }
  78. /**
  79. * {@inheritdoc}
  80. */
  81. public function getBlockPrefix(): string
  82. {
  83. return 'front_busqueda_jornadas_cursos';
  84. }
  85. }