You are here

function recaptcha_v3_ajax_callback in reCAPTCHA v3 8

AJAX callback; return captcha response.

Parameters

array $form: An array of $form.

\Drupal\Core\Form\FormStateInterface $form_state: The recaptcha v3 form state.

Return value

\Drupal\Core\Ajax\AjaxResponse Return captcha response.

1 string reference to 'recaptcha_v3_ajax_callback'
recaptcha_v3_captcha in ./recaptcha_v3.module
Implements hook_captcha().

File

./recaptcha_v3.module, line 292
Contains recaptcha_v3.module.

Code

function recaptcha_v3_ajax_callback(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $selector = '#' . $form['#id'] . ' .captcha';
  $response
    ->addCommand(new ReplaceCommand($selector, $form['captcha']));
  return $response;
}