src/Ox/HoardBundle/Form/ContactType.php line 20

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by IntelliJ IDEA.
  4.  * User: ahaith
  5.  * Date: 09/12/2015
  6.  * Time: 17:43
  7.  */
  8. namespace App\Ox\HoardBundle\Form;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Beelab\Recaptcha2Bundle\Form\Type\RecaptchaType;
  13. use Beelab\Recaptcha2Bundle\Validator\Constraints\Recaptcha2;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  16. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  17. class ContactType extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options)
  20.     {
  21.         $builder
  22.             ->add('name'TextType::class, array(
  23.                 'required' => true
  24.             ))
  25.             ->add('email'EmailType::class, array(
  26.                 'required' => true
  27.             ))
  28.             ->add('message'TextareaType::class, array(
  29.                 'required' => true,
  30.                 'attr' => array('class' => 'contact-message')
  31.             ))
  32.             ->add('captcha'RecaptchaType::class, [
  33.                 // You can use RecaptchaSubmitType
  34.                 // "groups" option is not mandatory
  35.                 'constraints' => new Recaptcha2(['groups' => ['create']]),
  36.             ])
  37.             ;
  38.     }
  39.     public function configureOptions(OptionsResolver $resolver)
  40.     {
  41.         $resolver->setDefaults(array(
  42.             'data_class' => null,
  43.         ));
  44.     }
  45.     public function getBlockPrefix()
  46.     {
  47.         return 'ox_hoardbundle_contact';
  48.     }
  49. }