src/Form/Type/Frontend/ContactProType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type\Frontend;
  3. use App\Form\Type\EWZRecaptchaCustomType;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  6. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  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\Length;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. class ContactProType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('firstname'TextType::class, [
  20.                 'label' => 'frontend.landing.contact.form.label.firstname',
  21.                 'constraints' => [
  22.                     new NotBlank(),
  23.                 ],
  24.             ])
  25.             ->add('lastname'TextType::class, [
  26.                 'label' => 'frontend.landing.contact.form.label.lastname',
  27.                 'constraints' => [
  28.                     new NotBlank(),
  29.                 ],
  30.             ])
  31.             ->add('email'EmailType::class, [
  32.                 'label' => 'frontend.landing.contact.form.label.email',
  33.                 'constraints' => [
  34.                     new NotBlank(),
  35.                     new Email(),
  36.                 ],
  37.             ])
  38.             ->add('companyName'TextType::class, [
  39.                 'label' => 'frontend.landing.contact-pro.form.label.CompanyName',
  40.                 'constraints' => [
  41.                     new NotBlank(),
  42.                 ],
  43.             ])
  44.             ->add('object'TextType::class, [
  45.                 'label' => 'frontend.landing.contact-pro.form.label.object',
  46.                 'constraints' => [
  47.                     new NotBlank(),
  48.                 ],
  49.             ])
  50.             ->add('message'TextareaType::class, [
  51.                 'label' => 'frontend.landing.contact-pro.form.label.message',
  52.                 'constraints' => [
  53.                     new NotBlank(),
  54.                     new Length(['min' => 10]),
  55.                 ],
  56.             ])
  57.             ->add('recaptcha'EWZRecaptchaCustomType::class)
  58.             ->add('send'SubmitType::class, [
  59.                 'label' => 'frontend.landing.contact.form.label.submit',
  60.                 'attr' => [
  61.                     'class' => 'lien14 bg04',
  62.                 ],
  63.             ])
  64.         ;
  65.     }
  66.     public function configureOptions(OptionsResolver $resolver)
  67.     {
  68.         $resolver->setDefaults([
  69.             'translation_domain' => 'landing',
  70.         ]);
  71.     }
  72. }