src/Form/Ecommerce/PickingUpType.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Form\Ecommerce;
  3. use App\Entity\ShippingData;
  4. use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints\Email;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. /**
  14.  * Class PickingUpType.
  15.  */
  16. class PickingUpType extends AbstractType
  17. {
  18.     /**
  19.      * @param FormBuilderInterface $builder
  20.      * @param array                $options
  21.      */
  22.     public function buildForm(FormBuilderInterface $builder, array $options)
  23.     {
  24.         $builder
  25.             ->add('name'TextType::class, [
  26.                 'label' => 'form.global.label_name',
  27.                 'required' => true,
  28.                 'constraints' => [new NotBlank(['groups' => ['PickUp']])]
  29.             ])
  30.             ->add('surname'TextType::class, array(
  31.                 'label' => 'form.global.label_surname',
  32.                 'required' => true,
  33.                 'constraints' => [new NotBlank(['groups' => ['PickUp']])]
  34.             ))
  35.             ->add('email'EmailType::class,
  36.                 [
  37.                     'label' => 'form.global.label_email',
  38.                     'constraints' => [new Email(['groups' => ['PickUp']]), new NotBlank(['groups' => ['PickUp']])]
  39.                 ])
  40.             ->add('phone'PhoneNumberType::class, [
  41.                 'label' => 'form.global.label_phone',
  42.                 'required' => true,
  43.                 'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
  44.                 'preferred_country_choices' => ['ES'],
  45.                 'constraints' => [new NotBlank(['groups' => ['PickUp']])]
  46.             ])
  47.             ->add('comment'TextareaType::class, [
  48.                 'label' => 'form.global.label_message',
  49.                 'required' => false,
  50.             ]);
  51.     }
  52.     /**
  53.      * @param OptionsResolver $resolver
  54.      */
  55.     public function configureOptions(OptionsResolver $resolver)
  56.     {
  57.         $resolver->setDefaults(array(
  58.             'data_class' => ShippingData::class,
  59.         ));
  60.     }
  61.     /**
  62.      * @return string
  63.      */
  64.     public function getName()
  65.     {
  66.         return 'app_picking_up_type';
  67.     }
  68. }