Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Options form #284

Open
rzp-789 opened this issue Feb 18, 2022 · 0 comments
Open

Problems with Options form #284

rzp-789 opened this issue Feb 18, 2022 · 0 comments

Comments

@rzp-789
Copy link

rzp-789 commented Feb 18, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant