src/MDS/GreenPatioBundle/Form/ReservationType.php line 89

Open in your IDE?
  1. <?php
  2. namespace App\MDS\GreenPatioBundle\Form;
  3. use App\Entity\Client;
  4. use App\Entity\Supplier;
  5. use App\MDS\GreenPatioBundle\Entity\Reservation;
  6. use App\Repository\SupplierRepository;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  11. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  12. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  15. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  16. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  17. class ReservationType extends AbstractType
  18. {
  19.     /**
  20.      * {@inheritdoc}
  21.      */
  22.     public function buildForm(FormBuilderInterface $builder, array $options)
  23.     {
  24.         $data $builder->getData();            // usado para  ->add('cateringName', EntityType::class, array(
  25. //        $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'onPreSetData'));
  26. //        $builder->addEventListener(FormEvents::PRE_SUBMIT, array($this, 'onPreSubmit'));
  27.         $builder
  28.             ->add('title'TextType::class, array(
  29.                 'required' => true))
  30. //            ->add('createdAt')
  31. //            ->add('createdBy', TextType::class, array(
  32. //                'required' => false))
  33. //            ->add('supplier', TextType::class, array(
  34. //                'required' => false))
  35. //            ->add('status')
  36.             ->add('status'ChoiceType::class, array(
  37.                 'required' => false,
  38.                 'choices' => array(
  39.                     'Iniciado' => 'Iniciado',
  40.                     'Bloqueo' => 'Bloqueo',
  41.                     'Confirmado' => 'Confirmed',
  42.                     'Cotizado' => 'Cotizado',
  43.                     'Facturado' => 'Invoiced'
  44.                 ), 'placeholder' => 'Select a status'))
  45.             ->add('priority'ChoiceType::class, array(
  46.                 'required' => false,
  47.                 'choices' => array(
  48.                     '1' => '1',
  49.                     '2' => '2',
  50.                     '3' => '3',
  51.                     '4' => '4',
  52.                     '5' => '5',
  53.                     '6' => '6',
  54.                     '7' => '7',
  55.                     '8' => '8',
  56.                     '9' => '9',
  57.                     '10' => '10'
  58.                 ), 'placeholder' => 'Auto'))
  59.             ->add('client'EntityType::class, array(
  60.                 'required' => false,
  61.                 'class' => Client::class,
  62.                 'choice_label' => 'name',
  63.                 'choice_value' => 'id',
  64.                 'expanded' => false,
  65.                 'multiple' => false,
  66.                 'placeholder' => 'Select a Client'))
  67.             ->add('clientContact'HiddenType::class)
  68.             ->add('contactUnregistered'HiddenType::class, array(
  69.                 'required' => true))
  70.             ->add('days'HiddenType::class)
  71.             ->add('cateringName'EntityType::class, array(
  72.                 'class' => Supplier::class,
  73.                 'choice_label' => 'name',
  74.                 'choice_value' => 'id',
  75.                 'required' => false,
  76.                 'multiple' => false,
  77.                 'placeholder' => 'Select a Supplier',
  78.                 'query_builder' => function (SupplierRepository $er) use ($data) {
  79.                     $qb $er->createQueryBuilder('e')
  80.                         ->where('e.tags like :manufacturer')
  81.                         ->setParameter('manufacturer''catering');
  82.                     return $qb->orderBy('e.company');
  83.                 }
  84.                 ))
  85.             ->add('advancePayment'IntegerType::class, array(
  86.                 'required' => false))
  87.             ->add('daysBlock'IntegerType::class, array(
  88.                 'data' => 7,
  89.                 'required' => false))
  90.             ->add('idProposal'IntegerType::class, array(
  91.                 'required' => false))
  92.             ->add('pax'IntegerType::class, array(
  93.                 'required' => false))
  94.             ->add('deposit'IntegerType::class, array(
  95.                 'required' => false))
  96.             ->add('description'TextareaType::class, array(
  97.                 'required' => false))
  98.             ->add('save'SubmitType::class);
  99.     }
  100.     
  101.     /**
  102.      * {@inheritdoc}
  103.      */
  104.     public function configureOptions(OptionsResolver $resolver)
  105.     {
  106.         $resolver->setDefaults(array(
  107.             'data_class' => Reservation::class
  108.         ));
  109.     }
  110.     /**
  111.      * {@inheritdoc}
  112.      */
  113.     public function getBlockPrefix()
  114.     {
  115.         return 'mds_greenpatiobundle_reservation';
  116.     }
  117. }