Skip to content

Commit 5bc298d

Browse files
authored
1 parent 7493759 commit 5bc298d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/ReCaptcha.php

+22
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,29 @@ public function getWidget($theme = 'light', $type = 'image')
142142
{
143143
return sprintf('<div class="g-recaptcha" data-sitekey="%s" data-theme="%s" data-type="%s"></div>', $this->siteKey, $theme, $type);
144144
}
145+
146+
/**
147+
* Render a button for the invisible captcha
148+
*
149+
* @param $formId
150+
* @param string $buttonLabel
151+
* @param string $buttonClass
152+
* @return string
153+
*/
154+
public function getInvisibleWidget($formId, $buttonLabel = 'Submit', $buttonClass ='')
155+
{
156+
$hash = md5(uniqid($formId, true));
145157

158+
return sprintf(
159+
'<script>
160+
function onSubmit%s(token) {
161+
document.getElementById("%s").submit();
162+
}
163+
</script>
164+
<button class="g-recaptcha %s" data-sitekey="%s" data-callback=\'onSubmit%s\'>%s</button>
165+
', $hash, $formId, $buttonClass, $this->siteKey, $hash, $buttonLabel);
166+
}
167+
146168
/**
147169
* Verify a response string
148170
*

0 commit comments

Comments
 (0)