You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7KB

  1. <?php
  2. namespace Lc\SovBundle\Form\User;
  3. use Lc\SovBundle\Doctrine\EntityManager;
  4. use Lc\SovBundle\Translation\TranslatorAdmin;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\ButtonType;
  7. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  8. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class ConfirmDeleteUserFormType extends AbstractType
  12. {
  13. protected $em;
  14. protected $translatorAdmin;
  15. public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
  16. {
  17. $this->em = $em;
  18. $this->translatorAdmin = $translatorAdmin;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function buildForm(FormBuilderInterface $builder, array $options)
  24. {
  25. $builder->add(
  26. 'confirm',
  27. CheckboxType::class,
  28. [
  29. 'translation_domain' => 'admin',
  30. ]
  31. );
  32. $builder->add(
  33. 'delete',
  34. SubmitType::class
  35. );
  36. }
  37. public function configureOptions(OptionsResolver $resolver): void
  38. {
  39. $resolver->setDefaults([
  40. // enable/disable CSRF protection for this form
  41. 'csrf_protection' => true,
  42. // the name of the hidden HTML field that stores the token
  43. 'csrf_field_name' => '_token',
  44. // an arbitrary string used to generate the value of the token
  45. // using a different string for each form improves its security
  46. 'csrf_token_id' => 'ea-delete',
  47. ]);
  48. }
  49. }