src/Form/Front/ContactInvestorType.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Form\Front;
  3. use App\Entity\Accommodation;
  4. use App\Entity\ContactMessage;
  5. use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
  6. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
  7. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  13. use Symfony\Component\Form\FormBuilderInterface;
  14. use Symfony\Component\OptionsResolver\OptionsResolver;
  15. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  16. use Symfony\Component\Form\Extension\Core\Type\TextType;
  17. use Symfony\Component\Routing\RouterInterface;
  18. class ContactInvestorType extends AbstractType
  19. {
  20.     private $router;
  21.     public function __construct(RouterInterface $router)
  22.     {
  23.         $this->router $router;
  24.     }
  25.     public function buildForm(FormBuilderInterface $builder, array $options)
  26.     {
  27.         $builder
  28.             ->add('recaptcha'EWZRecaptchaType::class, [
  29.                 'attr'        => [
  30.                     'options' => [
  31.                         'theme' => 'light',
  32.                         'type'  => 'image',
  33.                         'size'  => 'small',
  34.                     ]
  35.                 ],
  36.                 'mapped'      => false,
  37.                 'constraints' => array(
  38.                     new RecaptchaTrue()
  39.                 )
  40.             ])
  41.             ->add('firstname'TextType::class, array('attr' => ['placeholder' => 'label.firstname']))
  42.             ->add('lastname'TextType::class, array('attr' => ['placeholder' => 'label.lastname']))
  43.             ->add('email'EmailType::class, array('attr' => ['placeholder' => 'label.email']))
  44.             ->add('phone'TextType::class, array('attr' => ['placeholder' => 'label.phone']))
  45.             ->add('optin'CheckboxType::class, array('label' => 'label.acceptOptin''required' => true))
  46.         ;
  47.     }
  48.     public function configureOptions(OptionsResolver $resolver)
  49.     {
  50.         $resolver->setDefaults(array(
  51.             'data_class' => ContactMessage::class,
  52.             'translation_domain' => 'front',
  53.             'type' => '',
  54.         ));
  55.     }
  56. }