src/Form/Type/ContactType.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3.  * Contact Type
  4.  *
  5.  * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6.  */
  7. namespace App\Form\Type;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Routing\RouterInterface;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  15. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  16. use Symfony\Component\Validator\Constraints\NotBlank;
  17. use VisualMedia\LisaBundle\Form\Type\GoogleRecaptchaType;
  18. /**
  19.  * Contact Type
  20.  */
  21. class ContactType extends AbstractType
  22. {
  23.     /**
  24.      * Router
  25.      * @var RouterInterface
  26.      */
  27.     protected $router;
  28.     /**
  29.      * Constructor
  30.      */
  31.     public function __construct(RouterInterface $router)
  32.     {
  33.         $this->router $router;
  34.     }
  35.     /**
  36.      * {@inheritDoc}
  37.      */
  38.     public function buildForm(FormBuilderInterface $builder, array $options): void
  39.     {
  40.         $builder->add('contact'TextType::class, array(
  41.             'label' => 'contact.contact',
  42.             'trim' => true,
  43.         ));
  44.         $builder->add('email'EmailType::class, array(
  45.             'label' => 'contact.email',
  46.             'trim' => true,
  47.         ));
  48.         $builder->add('phone'TextType::class, array(
  49.             'label' => 'contact.phone',
  50.             'trim' => true,
  51.         ));
  52.         $builder->add('message'TextareaType::class, array(
  53.             'label' => 'contact.message',
  54.             'trim' => true,
  55.         ));
  56.         $builder->add('google_recaptcha'GoogleRecaptchaType::class, array());
  57.         $builder->add('submit'SubmitType::class, array('label' => 'contact.submit'));
  58.     }
  59.     /**
  60.      * {@inheritDoc}
  61.      */
  62.     public function getName(): string
  63.     {
  64.         return 'contact';
  65.     }
  66.     /**
  67.      * {@inheritDoc}
  68.      */
  69.     public function configureOptions(OptionsResolver $resolver) : void
  70.     {
  71.         $resolver->setDefaults(array(
  72.             'translation_domain' => 'forms',
  73.         ));
  74.     }
  75. }