src/Form/TicketType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Ticket;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. use Symfony\Component\Validator\Constraints\IsTrue;
  8. use Symfony\Component\Validator\Constraints\Length;
  9. use Symfony\Component\Validator\Constraints\NotBlank;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  12. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  13. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  14. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  15. class TicketType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options)
  18.     {
  19.         $builder
  20.             ->add('Nom'TextType::class, [
  21.                 'attr' => [
  22.                     'placeholder' => "Veuillez saisir votre nom.",
  23.                     'class' => 'form-control'
  24.                 ],
  25.                 'constraints' => [
  26.                     new length([
  27.                         'min' => 2,
  28.                         'minMessage' => 'Votre nom doit contenir au moins 2 caractères',
  29.                     ]),
  30.                 ],
  31.                 'required' => true,
  32.             ])
  33.             ->add('Mail'EmailType::class, [
  34.                 'attr' => [
  35.                     'placeholder' => "Veuillez saisir votre adresse mail.",
  36.                     'class' => 'form-control'
  37.                 ],
  38.                 'constraints' => [
  39.                     new NotBlank([
  40.                         'message' => 'Merci de saisir une adresse mail.'
  41.                     ])
  42.                 ],
  43.                 'required' => true,
  44.             ])
  45.             ->add('sujet'ChoiceType::class, [
  46.                 'choices'  => [
  47.                     'Problème connexion authentification' => 'Probleme_connexion_authentification',
  48.                     'Modération' => 'Moderation',
  49.                     'Suggestion' => 'Suggestion',
  50.                     'Problème de recommandation' => 'Probleme_de_recommandation',
  51.                     'Fonctionnalités' => 'Fonctionnalites',
  52.                     'Autres' => 'Autres',
  53.                 ],
  54.             ])
  55.             ->add('Commentaire'TextareaType::class, [
  56.                 'attr' => [
  57.                     'placeholder' => "Veuillez expliquer votre problème.",
  58.                     'class' => 'form-control'
  59.                 ],
  60.                 'constraints' => [
  61.                     new NotBlank([
  62.                         'message' => 'Merci d\'expliquer votre problème.'
  63.                     ]),
  64.                     new Length([
  65.                         'max' => 4096,
  66.                     ]),
  67.                 ],
  68.                 'required' => true,
  69.             ])
  70.             
  71.         ;
  72.     }
  73.     public function configureOptions(OptionsResolver $resolver)
  74.     {
  75.         $resolver->setDefaults([
  76.             'data_class' => Ticket::class,
  77.         ]);
  78.     }
  79. }