<?php
namespace App\Form\Ecommerce;
use App\Entity\ShippingData;
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* Class PickingUpType.
*/
class PickingUpType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, [
'label' => 'form.global.label_name',
'required' => true,
'constraints' => [new NotBlank(['groups' => ['PickUp']])]
])
->add('surname', TextType::class, array(
'label' => 'form.global.label_surname',
'required' => true,
'constraints' => [new NotBlank(['groups' => ['PickUp']])]
))
->add('email', EmailType::class,
[
'label' => 'form.global.label_email',
'constraints' => [new Email(['groups' => ['PickUp']]), new NotBlank(['groups' => ['PickUp']])]
])
->add('phone', PhoneNumberType::class, [
'label' => 'form.global.label_phone',
'required' => true,
'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
'preferred_country_choices' => ['ES'],
'constraints' => [new NotBlank(['groups' => ['PickUp']])]
])
->add('comment', TextareaType::class, [
'label' => 'form.global.label_message',
'required' => false,
]);
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => ShippingData::class,
));
}
/**
* @return string
*/
public function getName()
{
return 'app_picking_up_type';
}
}