src/Form/ForumReportType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\ForumReport;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints\Length;
  11. class ForumReportType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $builder
  16.             ->add('type'ChoiceType::class, [
  17.                 'attr' => [
  18.                     'class' => 'with-border selectpicker',
  19.                 ],
  20.                 'choices' => [
  21.                     'Inappropriate or offensive content' => 'Inappropriate or offensive content',
  22.                     'Spam or unwanted content' => 'Spam or unwanted content',
  23.                     'Misleading or false information' => 'Misleading or false information',
  24.                     'Identity or impersonation' => 'Identity or impersonation',
  25.                     'Plagiarism or copyright violation' => 'Plagiarism or copyright violation',
  26.                     'Other' => 'Other',
  27.                 ],
  28.                 'expanded' => false
  29.             ])
  30.             ->add('remarque'TextareaType::class, [
  31.                 'attr' => [
  32.                     'class' => 'with-border selectpicker',
  33.                     'placeholder' => 'Message'
  34.                 ],
  35.                 'constraints' => [
  36.                     new Length([
  37.                         'max' => 300,
  38.                         'maxMessage' => 'Only { limit } characters',
  39.                     ])
  40.                 ]
  41.             ])
  42.             ->add('report_entity'HiddenType::class, [
  43.                 'mapped' => false
  44.             ])
  45.             ->add('rubrique_id'HiddenType::class, [
  46.                 'mapped' => false
  47.             ])
  48.         ;
  49.     }
  50.     public function configureOptions(OptionsResolver $resolver): void
  51.     {
  52.         $resolver->setDefaults([
  53.             'data_class' => ForumReport::class,
  54.         ]);
  55.     }
  56. }