<?php
/**
* Created by IntelliJ IDEA.
* User: ahaith
* Date: 09/12/2015
* Time: 17:43
*/
namespace App\Ox\HoardBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Beelab\Recaptcha2Bundle\Form\Type\RecaptchaType;
use Beelab\Recaptcha2Bundle\Validator\Constraints\Recaptcha2;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, array(
'required' => true
))
->add('email', EmailType::class, array(
'required' => true
))
->add('message', TextareaType::class, array(
'required' => true,
'attr' => array('class' => 'contact-message')
))
->add('captcha', RecaptchaType::class, [
// You can use RecaptchaSubmitType
// "groups" option is not mandatory
'constraints' => new Recaptcha2(['groups' => ['create']]),
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => null,
));
}
public function getBlockPrefix()
{
return 'ox_hoardbundle_contact';
}
}