deblan.io-murph/src/Form/ContactType.php

96 lines
2.4 KiB
PHP
Raw Normal View History

2021-03-29 14:33:46 +02:00
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
2021-03-30 13:40:46 +02:00
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
2021-03-29 14:33:46 +02:00
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
2021-03-30 13:40:46 +02:00
use Symfony\Component\Validator\Constraints\NotBlank;
2022-05-29 21:04:28 +02:00
use Gregwar\CaptchaBundle\Type\CaptchaType;
2021-03-29 14:33:46 +02:00
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'name',
TextType::class,
[
'label' => 'Nom',
'required' => true,
'attr' => [
],
'constraints' => [
new NotBlank(),
],
]
);
$builder->add(
'subject',
TextType::class,
[
'label' => 'Sujet',
'required' => true,
'attr' => [
],
'constraints' => [
new NotBlank(),
],
]
);
$builder->add(
'email',
EmailType::class,
[
'label' => 'E-mail',
'required' => true,
'attr' => [
],
'constraints' => [
new NotBlank(),
new Email(),
],
]
);
$builder->add(
'message',
TextareaType::class,
[
'label' => 'Message',
'required' => true,
'attr' => [
],
'constraints' => [
new NotBlank(),
],
]
);
2022-05-29 21:04:28 +02:00
$builder->add(
'captcha',
CaptchaType::class,
[
'invalid_message' => 'Code invalide',
'label' => 'Captcha',
'max_front_lines' => 1,
'width' => 140,
'height' => 50,
'length' => 3,
]
);
2021-03-29 14:33:46 +02:00
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
]);
}
}