Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Problems with Options form #284

Description

@rzp-789

i follow the docs

my ewz_recaptcha.yaml :

# See https://github.com/excelwebzone/EWZRecaptchaBundle for full configuration
ewz_recaptcha:
    public_key:  '%env(EWZ_RECAPTCHA_SITE_KEY)%'
    private_key: '%env(EWZ_RECAPTCHA_SECRET)%'

    version: 2
    enabled: true
    api_host: recaptcha.net
    verify_host: true

My form :

<?php

declare(strict_types=1);

namespace App\Form\Extension;

use App\Form\FormHelper;
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerProfileType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;

class BaseCustomerTypeExtension extends AbstractTypeExtension
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->remove('gender')
            ->add('phoneNumber', TelType::class, [
                'label' => 'app.form.phone',
                'constraints' => $this->getPhoneNumberConstraints(),
            ])
            ->add('isAgreeToReceiveByMail', CheckboxType::class, [
                'label' => 'app.form.mail',
            ])
            ->add('isAgreeToReceiveBySms', CheckboxType::class, [
                'label' => 'app.form.sms',
            ])
            ->add('isAgreeToReceiveByCourier', CheckboxType::class, [
                'label' => 'app.form.courier',
            ])
            ->add('recaptcha', EWZRecaptchaType::class, array(
                'attr' => array(
                    'options' => array(
                        'theme' => 'light',
                        'type'  => 'image',
                        'size'  => 'normal',
                        'defer' => true,
                        'async' => true,
                    )
                )
            ))
        ;
    }

    public static function getExtendedTypes(): iterable
    {
        return [CustomerProfileType::class];
    }

    private function getPhoneNumberConstraints(): array
    {
        return [
            new NotBlank(FormHelper::getDefaultSyliusValidationGroup()),
        ];
    }
}

added on the twig :

{{ form_row(form.recaptcha) }}

Error =>
error captcha

if you have an idea, i try too for version 3 but the problem is same with an other option

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions