A bit difficult to know where to put this but we had an issue concerning (invisible) recaptcha (with the invisible recaptcha patch from issue 2852269) , webform and webform_multifile.
The problem here is the asynchronous callback from invisible recaptcha wich is hardcoded in the recaptcha module. However because it invokes the submit on the form, the "Empty Element Fix" of jquery.MultiFile is not executed and you get a form validation error because you submit an "empty" attachment.
I added a drupal_alter in the recaptcha_captcha(...) function so I can alter the .js callback and implement one myself, invoking the necessary js from webform_multifile. This alter is generic and other modules could benefit from it as well I suppose. It defaults to the recaptcha module's implementation of course.
I added an example in attached txt (and changed code below) but did not provide a patch because it would be a patch from a patch (see related issue)...
recaptcha.module:
if ('invisible' === $attributes['data-size']) {
// added an alter, defaulting to 'onInvisibleSubmit'
drupal_alter('recaptcha_callback', $callback, $captcha);
$callback = isset($callback) ? $callback : 'onInvisibleSubmit';
$attributes['data-callback'] = $callback;
$default_js = array(
drupal_get_path('module', 'recaptcha') . '/js/invisible-recaptcha.js',
);
// alters can also provide their own js file(s) so merge this with the default implementation
if(isset($captcha['form']['#attached']['js'])) {
$captcha['form']['#attached']['js'] = array_merge($default_js, $captcha['form']['#attached']['js']);
} else {
$captcha['form']['#attached']['js'] = $default_js;
}
}
Comment | File | Size | Author |
---|---|---|---|
recaptcha_api.txt | 2.15 KB | lorenzs |
Comments
Comment #2
hass CreditAttribution: hass commented