3 namespace Rapsys\AirBundle\Form
;
5 use Symfony\Component\Form\AbstractType
;
6 use Symfony\Component\Form\FormBuilderInterface
;
7 use Symfony\Component\OptionsResolver\OptionsResolver
;
8 use Symfony\Component\Form\Extension\Core\Type\TextType
;
9 use Symfony\Component\Form\Extension\Core\Type\TextareaType
;
10 use Symfony\Component\Form\Extension\Core\Type\EmailType
;
11 use Symfony\Component\Form\Extension\Core\Type\SubmitType
;
12 use Symfony\Component\Validator\Constraints\Email
;
13 use Symfony\Component\Validator\Constraints\NotBlank
;
15 class ContactType
extends AbstractType
{
19 public function buildForm(FormBuilderInterface
$builder, array $options) {
20 return $builder->add('name', TextType
::class, array('attr' => array('placeholder' => 'Your name'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your name')))))
21 ->add('subject', TextType
::class, array('attr' => array('placeholder' => 'Subject'), 'constraints' => array(new NotBlank(array('message' => 'Please provide your subject')))))
22 ->add('mail', EmailType
::class, array('attr' => array('placeholder' => 'Your mail address'), 'constraints' => array(new NotBlank(array('message' => 'Please provide a valid mail')), new Email(array('message' => 'Your mail doesn\'t seems to be valid')))))
23 ->add('message', TextareaType
::class, array('attr' => array('placeholder' => 'Your message here', 'cols' => 50, 'rows' => 15), 'constraints' => array(new NotBlank(array('message' => 'Please provide your message')))))
24 ->add('submit', SubmitType
::class, array('label' => 'Send', 'attr' => array('class' => 'submit')));
30 public function configureOptions(OptionsResolver
$resolver) {
31 $resolver->setDefaults(['error_bubbling' => true]);
37 public function getName() {
38 return 'contact_form';