<?php
namespace App\Form\Type\Frontend;
use App\Form\Type\EWZRecaptchaCustomType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
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\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class ContactProType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstname', TextType::class, [
'label' => 'frontend.landing.contact.form.label.firstname',
'constraints' => [
new NotBlank(),
],
])
->add('lastname', TextType::class, [
'label' => 'frontend.landing.contact.form.label.lastname',
'constraints' => [
new NotBlank(),
],
])
->add('email', EmailType::class, [
'label' => 'frontend.landing.contact.form.label.email',
'constraints' => [
new NotBlank(),
new Email(),
],
])
->add('companyName', TextType::class, [
'label' => 'frontend.landing.contact-pro.form.label.CompanyName',
'constraints' => [
new NotBlank(),
],
])
->add('object', TextType::class, [
'label' => 'frontend.landing.contact-pro.form.label.object',
'constraints' => [
new NotBlank(),
],
])
->add('message', TextareaType::class, [
'label' => 'frontend.landing.contact-pro.form.label.message',
'constraints' => [
new NotBlank(),
new Length(['min' => 10]),
],
])
->add('recaptcha', EWZRecaptchaCustomType::class)
->add('send', SubmitType::class, [
'label' => 'frontend.landing.contact.form.label.submit',
'attr' => [
'class' => 'lien14 bg04',
],
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'translation_domain' => 'landing',
]);
}
}