|
- <?php
-
- namespace Lc\SovBundle\Component;
-
- use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- use Symfony\Component\Form\FormBuilderInterface;
-
- class FormComponent
- {
- protected ParameterBagInterface $parameterBag;
-
- public function __construct(ParameterBagInterface $parameterBag)
- {
- $this->parameterBag = $parameterBag;
- }
-
- public function addCaptchaType(FormBuilderInterface $builder)
- {
- $builder->add('specialField', HiddenType::class, [
- 'data' => 0,
- 'mapped' => false,
- 'attr' => [
- 'class' => 'special-field'
- ],
- 'constraints' => [
- new NotNull(),
- new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte'])
- ],
- ]);
- }
-
- }
|