src/Form/Booking/BookingType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form\Booking;
  3. use App\Entity\Booking\Booking;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  8. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  9. use App\Form\User\AccountType;
  10. class BookingType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('adults'null, [
  16.                 'label' => 'app.booking.form.adults',
  17.                 'required' => false,
  18.                 'attr' => ['placeholder' => 'app.booking.form.adults''min' => 1'max' => 10]
  19.             ])
  20.             ->add('childrens'null, [
  21.                 'label' => 'app.booking.form.childrens',
  22.                 'required' => false,
  23.                 'attr' => ['placeholder' => 'app.booking.form.childrens''min' => 0'max' => 10]
  24.             ])
  25.             ->add('customer'AccountType::class, [
  26.                 'label' => false
  27.             ])
  28.             // ->add('type', ChoiceType::class, [
  29.             //     'label' => false,
  30.             //     'required' => true,
  31.             //     'placeholder' => 'app.booking.form.type',
  32.             //     'choices'  => [
  33.             //         'app.theme.horse' => 'horse',
  34.             //         'app.theme.camel' => 'camel',
  35.             //         'app.theme.quad' => 'quad'
  36.             //     ],
  37.             //     'data' => 'horse'
  38.             // ])
  39.             ->add('reservationDate'DateTimeType::class, array(
  40.                 'label' => 'app.booking.form.date',
  41.                 'widget' => 'single_text',
  42.                 'attr' => ['style' => 'padding: 0 20px']
  43.             ))
  44.             ->add('location'ChoiceType::class, [
  45.                 'label' => 'app.booking.form.location',
  46.                 'placeholder' => 'app.booking.form.location.title',
  47.                 'required' => true,
  48.                 'choices'  => [
  49.                     'app.booking.form.location.agafay' => 'agafay',
  50.                     'app.booking.form.location.marrakech' => 'marrakech',
  51.                     // 'app.booking.form.location.agadir' => 'agadir',
  52.                 ],
  53.             ])
  54.             ->add('notes'null, [
  55.                 'label' => 'app.booking.form.notes',
  56.                 'required' => false,
  57.                 'attr' => ['placeholder' => 'app.booking.form.notes''rows' => 13]
  58.             ])
  59.         ;
  60.     }
  61.     public function configureOptions(OptionsResolver $resolver): void
  62.     {
  63.         $resolver->setDefaults([
  64.             'data_class' => Booking::class,
  65.         ]);
  66.     }
  67. }