82 lines
2 KiB
PHP
82 lines
2 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
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\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\Validator\Constraints\Email;
|
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
|
|
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(),
|
|
],
|
|
]
|
|
);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
]);
|
|
}
|
|
}
|