File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -63,16 +63,24 @@ public function run()
6363 $ this ->field ->template = "{input} \n{error} " ;
6464 $ formId = $ this ->field ->form ->id ;
6565 $ inputId = Html::getInputId ($ this ->model , $ this ->attribute );
66+ $ callbackRandomString = time ();
67+
68+ $ options = array_merge ([
69+ 'onClick ' => "recaptchaCallback_ {$ callbackRandomString }() "
70+ ], $ this ->options );
71+
6672
6773 return
6874 Html::tag ('script ' , <<<JS
69- grecaptcha.ready(function() {
70- grecaptcha.execute(' {$ this ->_component ->site_key }', {action: ' {$ this ->actionName }'}).then(function(token) {
71- alert(token);
72- $('# {$ inputId }').val(token);
73- $('# {$ formId }').submit();
74- });
75- });
75+ 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+ });
83+ }
7684JS
7785 )
7886 . Html::activeHiddenInput ($ this ->model , $ this ->attribute )
You can’t perform that action at this time.
0 commit comments