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.

66 lines
1.8KB

  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. 'confirmDelete',
  27. CheckboxType::class,
  28. [
  29. 'translation_domain' => 'admin',
  30. ]
  31. );
  32. $builder->add(
  33. 'delete',
  34. SubmitType::class,
  35. array(
  36. 'label'=> 'action.delete'
  37. )
  38. );
  39. }
  40. public function configureOptions(OptionsResolver $resolver): void
  41. {
  42. $resolver->setDefaults([
  43. // enable/disable CSRF protection for this form
  44. 'csrf_protection' => true,
  45. // the name of the hidden HTML field that stores the token
  46. 'csrf_field_name' => '_token',
  47. // an arbitrary string used to generate the value of the token
  48. // using a different string for each form improves its security
  49. 'csrf_token_id' => 'ea-delete',
  50. 'translation_domain'=> 'admin'
  51. ]);
  52. }
  53. }