Skip to content

Commit

Permalink
RE #154: Sets the default callback when using "size = invisible"
Browse files Browse the repository at this point in the history
  • Loading branch information
excelwebzone committed May 19, 2017
1 parent 26d9eee commit 7adf427
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Tests/Form/Type/EWZRecaptchaTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function configureOptions()
'size' => 'normal',
'callback' => null,
'expiredCallback' => null,
'bind' => null,
'defer' => false,
'async' => false,
),
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/views/Form/ewz_recaptcha_widget.html.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php if ($ewz_recaptcha_enabled): ?>
<?php if (!$ewz_recaptcha_ajax): ?>
<?php if ($attr['options']['size'] == 'invisible' && !isset($attr['options']['callback'])): ?>
<?php $attr['options']['callback'] = 'onReCaptchaSuccess' ?>

<script type="text/javascript">
var onReCaptchaSuccess = function() {
var errorDivs = document.getElementsByClassName('recaptcha-error');
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/views/Form/ewz_recaptcha_widget.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{% if form.vars.ewz_recaptcha_enabled %}
{% if not form.vars.ewz_recaptcha_ajax %}
{% if attr.options.size == 'invisible' and attr.options.callback is not defined %}
{% set options = options|merge({'callback': 'onReCaptchaSuccess'}) %}
{% set attr = attr|merge({'options': options}) %}

<script type="text/javascript">
var onReCaptchaSuccess = function() {
var errorDivs = document.getElementsByClassName('recaptcha-error');
Expand Down

0 comments on commit 7adf427

Please sign in to comment.