src/Form/ContactUsType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\BlackList;
  4. use App\Entity\ContactUs;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\Validator\Constraints\NotBlank;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. class ContactUsType extends AbstractType
  14. {
  15.     public function __construct(private TranslatorInterface $translator)
  16.     {
  17.     }
  18.     public function buildForm(FormBuilderInterface $builder, array $options): void
  19.     {
  20.         $builder
  21.             ->add('name'TextType::class, [
  22.                 "label" => $this->translator->trans("Votre nom"),
  23.                 "trim" => true,
  24.                 "required" => false,
  25.                 "constraints" => [
  26.                 ]
  27.             ])
  28.             ->add('surname'TextType::class, [
  29.                 "label" => $this->translator->trans("Votre prĂ©nom"),
  30.                 "trim" => true,
  31.                 "required" => false,
  32.                 "constraints" => [
  33.                 ]
  34.             ])
  35.             ->add('email'EmailType::class, [
  36.                 "label" => $this->translator->trans("Votre adresse email"),
  37.                 "trim" => true,
  38.                 "required" => false,
  39.                 'attr' => [
  40.                     'class' => 'theme-input-style',
  41.                 ],
  42.                 "constraints" => [
  43.                     new NotBlank(["message" => $this->translator->trans("Adresse email obligatoire")]),
  44.                 ]
  45.             ])
  46.             ->add('message'TextareaType::class, [
  47.                 "label" => $this->translator->trans("Veuillez mettre ci-dessous votre message"),
  48.                 "trim" => true,
  49.                 "required" => true,
  50.                 'attr' => [
  51.                     'class' => 'theme-input-style',
  52.                     'id'=>'exampleTextarea1',
  53.                     
  54.                 ],
  55.                 "constraints" => [
  56.                     new NotBlank(["message" => $this->translator->trans("Message obligatoire")]),
  57.                 ]
  58.             ]);
  59.     }
  60.     public function configureOptions(OptionsResolver $resolver): void
  61.     {
  62.         $resolver->setDefaults([
  63.             'data_class' => ContactUs::class,
  64.         ]);
  65.     }
  66. }