Skip to content

Commit 9bd2e29

Browse files
Bahaa OdehBahaa Odeh
authored andcommitted
add widget
1 parent 418c3a7 commit 9bd2e29

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

RecaptchaV3Widget.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function init()
5353
}
5454

5555

56-
5756
/**
5857
* @inheritdoc
5958
*/
@@ -73,17 +72,21 @@ public function run()
7372
return
7473
Html::tag('script', <<<JS
7574
var recaptchaCallback_{$callbackRandomString} = function() {
76-
grecaptcha.ready(function() {
77-
grecaptcha.execute('{$this->_component->site_key}', {action: '{$this->actionName}'}).then(function(token) {
78-
alert(token);
79-
$('#{$inputId}').val(token);
80-
$('#{$formId}').submit();
81-
});
82-
});
75+
if(!$('#{$inputId}').val()){
76+
grecaptcha.ready(function() {
77+
grecaptcha.execute('{$this->_component->site_key}', {action: '{$this->actionName}'}).then(function(token) {
78+
alert(token);
79+
$('#{$inputId}').val(token);
80+
$('#{$formId}').submit();
81+
});
82+
});
83+
}else{
84+
$('#{$formId}').submit();
85+
}
8386
}
8487
JS
8588
)
8689
. Html::activeHiddenInput($this->model, $this->attribute)
87-
. Html::button($this->buttonText, $this->options);
90+
. Html::button($this->buttonText, $options);
8891
}
8992
}

0 commit comments

Comments
 (0)