src/Form/QuotationType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Quotation;
  4. use Karser\Recaptcha3Bundle\Form\Recaptcha3Type;
  5. use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. class QuotationType extends AbstractType
  15. {
  16.     public function __construct(EntityManagerInterface $em)
  17.     {
  18.         $this->em $em;
  19.     }
  20.     public function buildForm(FormBuilderInterface $builder, array $options)
  21.     {
  22.         $builder
  23.             ->add('company'TextType::class, [
  24.                 'required' => true,
  25.                 'attr' => ['placeholder' => 'Votre société ou organisme'],
  26.                 'label' => 'Société ou organisme'
  27.             ])
  28.             ->add('firstname'TextType::class, [
  29.                 'required' => true,
  30.                 'attr' => ['placeholder' => 'Votre prénom'],
  31.                 'label' => 'Prénom'
  32.             ])
  33.             ->add('lastname'TextType::class, [
  34.                 'required' => true,
  35.                 'attr' => ['placeholder' => 'Votre Nom'],
  36.                 'label' => 'Nom'
  37.             ])
  38.             ->add('phone'TextType::class, [
  39.                 'required' => true,
  40.                 'attr' => ['placeholder' => '0100000000'],
  41.                 'label' => 'Téléphone'
  42.             ])
  43.             ->add('email'EmailType::class, [
  44.                 'required' => true,
  45.                 'attr' => ['placeholder' => 'email@domain.fr'],
  46.                 'label' => 'Email'
  47.             ])
  48.             ->add('message'TextareaType::class, [
  49.                 'required' => false,
  50.                 'attr' => ['placeholder' => 'Descriptif du projet'],
  51.                 'label' => 'Votre projet en quelques mots '
  52.             ])
  53.             ->add('captcha'Recaptcha3Type::class, [
  54.                 'constraints' => new Recaptcha3(),
  55.                 'action_name' => 'quotation',
  56.             ])
  57.             ->add('quotationEditSubmit'SubmitType::class, [
  58.                 'attr' => ['class' => 'btn btn-large waves-effect waves-light light-green'],
  59.                 'label' => 'Envoyer la demande'
  60.             ]);
  61.     }
  62.     public function configureOptions(OptionsResolver $resolver)
  63.     {
  64.         $resolver->setDefaults([
  65.             'data_class' => Quotation::class,
  66.             'translation_domain' => 'forms'
  67.         ]);
  68.     }
  69. }