src/Form/HtItemType.php line 75

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Escandallo;
  4. use App\Entity\HtItem;
  5. use App\Entity\HtMenu;
  6. use App\MDS\GreenPatioBundle\Entity\ReservationLoungeDetails;
  7. use Doctrine\ORM\EntityRepository;
  8. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  11. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  12. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\Extension\Core\Type\TimeType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. class HtItemType extends AbstractType
  19. {
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $builder
  23.             ->add('loungeOther'TextType::class, [
  24.                 'required' => false,
  25.                 'attr' => [
  26.                     'class' => 'form-control loungeOther'
  27.                 ]
  28.             ])
  29.             ->add('observation'TextareaType::class, [
  30.                 'required' => false,
  31.                 'attr' => [
  32.                     'class' => 'summernote'
  33.                 ]
  34.             ])
  35.             ->add('dateStart'DateTimeType::class, [
  36.                 'html5' => true,
  37.                 'date_widget' => 'single_text',
  38.                 'time_widget' => 'single_text',
  39.                 'required' => false,
  40.             ])
  41.             ->add('hourEnd'TimeType::class, [
  42.                 'html5' => true,
  43.                 'widget' => 'single_text'
  44.             ])
  45.             ->add('gratitudes'NumberType::class, [
  46.                 'html5' => true,
  47.                 'required' => false,
  48.                 'attr' => [
  49.                     'class' => 'form-control'
  50.                 ]
  51.             ])
  52.             ->add('pax'NumberType::class, [
  53.                 'html5' => true,
  54.                 'attr' => [
  55.                     'class' => 'form-control'
  56.                 ],
  57.                 'required' => false,
  58.             ])
  59.             ->add('loungeGp'EntityType::class, [
  60.                 'class' => ReservationLoungeDetails::class,
  61.                 'expanded' => false,
  62.                 'multiple' => false,
  63.                 'choice_label' => 'name',
  64.                 'placeholder' => 'Selecciona una Sala de Greenpatio o Covarrubias',
  65.                 'required' => false,
  66.                 'attr' => [
  67.                     'class' => 'mante_select2 select_lounge_GP'
  68.                 ]
  69.             ])
  70.             ->add('htMenu'EntityType::class, [
  71.                 'class' => HtMenu::class,
  72.                 'query_builder' => function (EntityRepository $er) {
  73.                     return $er->createQueryBuilder('m')
  74.                         ->where('m.template = :template')
  75.                         ->orderBy('m.name''ASC')
  76.                         ->setParameter('template'1);
  77.                 },
  78.                 'expanded' => false,
  79.                 'multiple' => false,
  80.                 'choice_label' => 'name',
  81.                 'placeholder' => 'Selecciona un menĂº',
  82.                 'required' => false,
  83.                 'attr' => [
  84.                     'class' => 'mante_select2 menu',
  85.                 ],
  86.                 'mapped' => false
  87.             ])
  88.             ->add('htExtras'CollectionType::class, [
  89.                 'entry_type' => HtExtraItemType::class,
  90.                 'entry_options' => ['label' => false],
  91.                 'allow_add' => true,
  92.                 'allow_delete' => true,
  93.                 'by_reference' => false,
  94.             ])
  95.         ;
  96.     }
  97.     public function configureOptions(OptionsResolver $resolver): void
  98.     {
  99.         $resolver->setDefaults([
  100.             'data_class' => HtItem::class,
  101.         ]);
  102.     }
  103. }