<?php
namespace App\Form;
use App\Entity\Quotation;
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\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\EntityManagerInterface;
class QuotationType extends AbstractType
{
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('company', TextType::class, [
'required' => true,
'attr' => ['placeholder' => 'Votre société ou organisme'],
'label' => 'Société ou organisme'
])
->add('firstname', TextType::class, [
'required' => true,
'attr' => ['placeholder' => 'Votre prénom'],
'label' => 'Prénom'
])
->add('lastname', TextType::class, [
'required' => true,
'attr' => ['placeholder' => 'Votre Nom'],
'label' => 'Nom'
])
->add('phone', TextType::class, [
'required' => true,
'attr' => ['placeholder' => '0100000000'],
'label' => 'Téléphone'
])
->add('email', EmailType::class, [
'required' => true,
'attr' => ['placeholder' => 'email@domain.fr'],
'label' => 'Email'
])
->add('message', TextareaType::class, [
'required' => false,
'attr' => ['placeholder' => 'Descriptif du projet'],
'label' => 'Votre projet en quelques mots '
])
->add('captcha', Recaptcha3Type::class, [
'constraints' => new Recaptcha3(),
'action_name' => 'quotation',
])
->add('quotationEditSubmit', SubmitType::class, [
'attr' => ['class' => 'btn btn-large waves-effect waves-light light-green'],
'label' => 'Envoyer la demande'
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Quotation::class,
'translation_domain' => 'forms'
]);
}
}