src/Application/Front/Form/ContactType.php line 16
<?php
namespace App\Application\Front\Form;
use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name',TextType::class, [
'label' => false,
'attr' => [
'placeholder' => 'Nom',
],
])
->add('email',EmailType::class, [
'label' => false,
'attr' => [
'placeholder' => 'Email'
],
])
->add('message', TextareaType::class, [
'label' => false,
'attr' => [
'rows' => 5,
'placeholder' => 'Message'
],
])
->add('captcha', Recaptcha3Type::class, [
'constraints' => new Recaptcha3(),
'action_name' => 'lifeinthecloud_contact',
'locale' => 'fr',
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('type', 'invisible')
->setAllowedValues('type', ['checkbox', 'invisible']);
}
/**
* @inheritDoc
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['type'] = $options['type'];
}
}