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.

34 lines
967B

  1. <?php
  2. namespace Lc\SovBundle\Component;
  3. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  4. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. class FormComponent
  7. {
  8. protected ParameterBagInterface $parameterBag;
  9. public function __construct(ParameterBagInterface $parameterBag)
  10. {
  11. $this->parameterBag = $parameterBag;
  12. }
  13. public function addCaptchaType(FormBuilderInterface $builder)
  14. {
  15. $builder->add('specialField', HiddenType::class, [
  16. 'data' => 0,
  17. 'mapped' => false,
  18. 'attr' => [
  19. 'class' => 'special-field'
  20. ],
  21. 'constraints' => [
  22. new NotNull(),
  23. new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte'])
  24. ],
  25. ]);
  26. }
  27. }