mReCaptchaInvisible :: YesodReCaptcha site => MForm (HandlerFor site) (FormResult ())
mReCaptchaInvisible = fst <$> mReCaptcha
reCaptchaInvisible :: YesodReCaptcha site => AForm (HandlerFor site) ()
reCaptchaInvisible = formToAForm ((,[]) <$> mReCaptchaInvisible)
reCaptchaInvisibleButton :: YesodReCaptcha site => Maybe Text -> HandlerFor site (Text, WidgetFor site (), [(Text, Text)])
reCaptchaInvisibleButton mIdent = do
mReCaptchaLanguage <- reCaptchaLanguage
siteKey <- reCaptchaSiteKey
ident <- maybe newIdent return mIdent
let
scriptName = "reCaptchaOnSubmit_" <> ident
let
widget = do
case mReCaptchaLanguage of
Nothing ->
addScriptRemote "https://www.google.com/recaptcha/api.js"
Just hl ->
addScriptRemote $ "https://www.google.com/recaptcha/api.js?hl=" <> hl
[whamlet|<script>function #{scriptName} (token) { document.getElementById("#{ident}").submit(); } |]
return
( ident
, widget
, [("data-sitekey", siteKey), ("data-callback", scriptName)]
)
This is the easiest way I could figure out.
Feel free to add it if you like.