- Issue created by @dipakmdhrm
- @dipakmdhrm opened merge request.
Recaptcha allows adding expired and error callback attributes: https://developers.google.com/recaptcha/docs/display#render_param
Currently this is possible by implementing hook captcha alter:
/**
* Implements hook_captcha().
*/
function hook_captcha_alter(&$captcha, $info) {
// $form['elements']['captcha']['#attributes']['data-expired-callback'] = 'recaptchaExpired';
if ($info['module'] == 'recaptcha') {
$captcha['form']['recaptcha_widget']['#markup'] = preg_replace(
'/<div([^>]*)>/',
'<div$1 data-expired-callback="onRecaptchaExpired">',
$captcha['form']['recaptcha_widget']['#markup'],
1 // only replace the first occurrence
);
$captcha['form']['captcha_response']['#description'] = t('New description.');
}
}
This is not ideal, but gets the job done.
But the recaptcha.js
converts the attributes to camelCase using this.data()
. Google expects these to be in kebab-case.
1. Implement hook_captcha_alter
to add new attributes
2. The callbacks will fail due to recaptcha.js
using camelCase instead of kebab-case
Update recaptcha.js
to use kebab-case
Active
3.0
reCAPTCHA V2