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

Badge position #164

Closed
jakenoble opened this issue Jun 7, 2017 · 2 comments
Closed

Badge position #164

jakenoble opened this issue Jun 7, 2017 · 2 comments

Comments

@jakenoble
Copy link

Is there a way to position the badge as documented on https://developers.google.com/recaptcha/docs/invisible

I have tried many different ways but nothing works.

@Andyhutchings
Copy link

For any one else with this issue. You can overwrite the form theme template to include more data-attributes.

Create app/Resources/EWZRecaptchaBundle/views/Form/ewz_recaptcha_widget.html.twig and copy the contents of the same file from the bundle.

Changed the div that includes all the google recapcha data attribute settings to the following.

   <div class="g-recaptcha"
       data-sitekey="{{ form.vars.public_key }}"

       {% for dataAttr, dataValue in attr.options %}
             data-{{ dataAttr }}="{{ dataValue }}"
       {% endfor %}
   ></div>

You can then just add new options to the from field e.g

 $builder
      ->add('username', TextType::class)
      ->add('plainPassword', PasswordType::class)
      ->add('recaptcha', EWZRecaptchaType::class, array(
                'mapped' => false,
                'constraints' => array(new RecaptchaTrue()),
                'attr' => array(
                    'options' => array(
                        'theme' => 'light',
                        'type'  => 'image',
                        'size' => 'invisible',
                        'defer' => true,
                        'async' => true,
                        'callback' => 'onLoginFormSubmit',
                        'bind' => 'loginButton',
                        'badge' => 'inline '
                    )
                )
            ));

@miisieq
Copy link

miisieq commented Oct 10, 2017

Why we can't just add this option to the form (EWZRecaptchaType)?

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

4 participants