src/Form/SolicitudSocioType.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Provider;
  4. use App\Entity\SolicitudPublica;
  5. use App\Entity\User;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\HiddenField;
  7. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  13. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  14. use Symfony\Component\Form\Extension\Core\Type\TelType;
  15. use Symfony\Component\Form\Extension\Core\Type\TimeType;
  16. use Symfony\Component\Form\FormBuilderInterface;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. class SolicitudSocioType extends AbstractType
  19. {
  20.     public function buildForm(FormBuilderInterface $builder, array $options): void
  21.     {
  22.         $t1 = new \DateTime();
  23.         $t1->setTime(9,0);
  24.         $t2 = new \DateTime();
  25.         $t2->setTime(20,0);
  26.         $u $options['socio'];
  27. //        dd($u);
  28.         $builder
  29.             ->add('nombre'null, [
  30.                 'attr' => [
  31.                     'placeholder' => 'Nombre',
  32.                     'class' => 'uk-input',
  33.                     'value' => $u->getNombre(),
  34.                     'disabled' => true
  35.                 ]
  36.             ])
  37.             ->add('apellido'null, [
  38.                 'attr' => [
  39.                     'placeholder' => 'Apellido',
  40.                     'class' => 'uk-input',
  41.                     'value' => $u->getApellido1(),
  42.                     'disabled' => true
  43.                 ]
  44.             ])
  45.             ->add('telefono'TelType::class, [
  46.                 'attr' => [
  47.                     'placeholder' => 'Teléfono',
  48.                     'class' => 'uk-input',
  49.                     'value' => $u->getTel1(),
  50.                     'disabled' => true
  51.                 ]
  52.             ])
  53.             ->add('email'EmailType::class, [
  54.                 'attr' => [
  55.                     'placeholder' => 'Email',
  56.                     'class' => 'uk-input',
  57.                     'value' => $u->getEmail(),
  58.                     'disabled' => true
  59.                 ]
  60.             ])
  61. //            ->add('destino')
  62. //            ->add('cadena')
  63.             ->add('fechaEntrada'DateType::class, [
  64.                 'widget' => 'single_text',
  65.                 'attr' => [
  66.                     'class' => 'uk-input'
  67.                 ]
  68.             ])
  69.             ->add('fechaSalida'DateType::class, [
  70.                 'widget' => 'single_text',
  71.                 'attr' => [
  72.                     'class' => 'uk-input'
  73.                 ]
  74.             ])
  75.             ->add('adultos'IntegerType::class, [
  76.                 'attr' => [
  77.                     'class' => 'uk-input',
  78.                     'value' => 1,
  79.                     'min' => 1
  80.                 ]
  81.             ])
  82.             ->add('menores'IntegerType::class, [
  83.                 'attr' => [
  84.                     'class' => 'uk-input',
  85.                     'value' => 0,
  86.                     'min' => 0
  87.                 ]
  88.             ])
  89.             ->add('horaDeContactoDesde'TimeType::class,[
  90.                 'attr' => [
  91.                     'class' => 'uk-input',
  92.                     ],
  93.                 'widget' => 'single_text',
  94.                 'html5' => true,
  95.                 'help' => 'A partir de esta hora',
  96.                 'data' => $t1
  97.             ])
  98.             ->add('horaDeContactoHasta'TimeType::class,[
  99.                 'attr' => [
  100.                     'class' => 'uk-input',
  101.                     ],
  102.                 'widget' => 'single_text',
  103.                 'html5' => true,
  104.                 'help' => 'Hasta esta hora',
  105.                 'data' => $t2
  106.             ])
  107.             ->add('entiendo'CheckboxType::class, [
  108.                 'label' => 'Entiendo que esto es sólo una solicitud, y en ninguna manera constituye o garantiza Reservación en este Hotel.'
  109.             ])
  110.             ->add('autorizacion')
  111.             ->add('proveedor'EntityType::class, [
  112.                 'class' => Provider::class,
  113.                 'data' => $options['proveedor'],
  114.                 'disabled' => true,
  115.                 'attr' => [
  116.                     'class' => 'uk-input',
  117.                 ],
  118.             ])
  119.             ->add('esSocio'HiddenType::class, [
  120.                 'data' => true,
  121.             ])
  122.             ->add('socio'HiddenType::class, [
  123. //                'class' => User::class,
  124. //                'data' => $options['socio'],
  125. //                'disabled' => true,
  126. //                'attr' => [
  127. //                    'class' => 'uk-input',
  128. //                ],
  129.             ])
  130.         ;
  131.     }
  132.     public function configureOptions(OptionsResolver $resolver): void
  133.     {
  134.         $resolver->setDefaults([
  135.             'data_class' => SolicitudPublica::class,
  136.             'proveedor' => null,
  137.             'socio' => null,
  138.         ]);
  139.     }
  140. }