]> Raphaƫl G. Git Repositories - airbundle/blob - Form/ContactType.php
Add gitignore file
[airbundle] / Form / ContactType.php
1 <?php
2
3 namespace Rapsys\AirBundle\Form;
4
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;
14
15 class ContactType extends AbstractType {
16 /**
17 * {@inheritdoc}
18 */
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')));
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 public function configureOptions(OptionsResolver $resolver) {
31 $resolver->setDefaults(['error_bubbling' => true]);
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function getName() {
38 return 'contact_form';
39 }
40 }