]> Raphaƫl G. Git Repositories - airbundle/blob - Form/ContactType.php
Fix locale
[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
21 ->add('name', TextType::class, ['attr' => ['placeholder' => 'Your name'], 'constraints' => [new NotBlank(['message' => 'Please provide your name'])]])
22 ->add('subject', TextType::class, ['attr' => ['placeholder' => 'Subject'], 'constraints' => [new NotBlank(['message' => 'Please provide your subject'])]])
23 ->add('mail', EmailType::class, ['attr' => ['placeholder' => 'Your mail'], 'constraints' => [new NotBlank(['message' => 'Please provide a valid mail']), new Email(['message' => 'Your mail doesn\'t seems to be valid'])]])
24 ->add('message', TextareaType::class, ['attr' => ['placeholder' => 'Your message', 'cols' => 50, 'rows' => 15], 'constraints' => [new NotBlank(['message' => 'Please provide your message'])]])
25 ->add('submit', SubmitType::class, ['label' => 'Send', 'attr' => ['class' => 'submit']]);
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 public function configureOptions(OptionsResolver $resolver) {
32 $resolver->setDefaults(['error_bubbling' => true]);
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function getName() {
39 return 'contact_form';
40 }
41 }