<?php
namespace App\Form;
use App\Entity\Escandallo;
use App\Entity\HtItem;
use App\Entity\HtMenu;
use App\MDS\GreenPatioBundle\Entity\ReservationLoungeDetails;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class HtItemType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('loungeOther', TextType::class, [
'required' => false,
'attr' => [
'class' => 'form-control loungeOther'
]
])
->add('observation', TextareaType::class, [
'required' => false,
'attr' => [
'class' => 'summernote'
]
])
->add('dateStart', DateTimeType::class, [
'html5' => true,
'date_widget' => 'single_text',
'time_widget' => 'single_text',
'required' => false,
])
->add('hourEnd', TimeType::class, [
'html5' => true,
'widget' => 'single_text'
])
->add('gratitudes', NumberType::class, [
'html5' => true,
'required' => false,
'attr' => [
'class' => 'form-control'
]
])
->add('pax', NumberType::class, [
'html5' => true,
'attr' => [
'class' => 'form-control'
],
'required' => false,
])
->add('loungeGp', EntityType::class, [
'class' => ReservationLoungeDetails::class,
'expanded' => false,
'multiple' => false,
'choice_label' => 'name',
'placeholder' => 'Selecciona una Sala de Greenpatio o Covarrubias',
'required' => false,
'attr' => [
'class' => 'mante_select2 select_lounge_GP'
]
])
->add('htMenu', EntityType::class, [
'class' => HtMenu::class,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('m')
->where('m.template = :template')
->orderBy('m.name', 'ASC')
->setParameter('template', 1);
},
'expanded' => false,
'multiple' => false,
'choice_label' => 'name',
'placeholder' => 'Selecciona un menĂº',
'required' => false,
'attr' => [
'class' => 'mante_select2 menu',
],
'mapped' => false
])
->add('htExtras', CollectionType::class, [
'entry_type' => HtExtraItemType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => HtItem::class,
]);
}
}