You are here

function fancy_login_user_pass_ajax_callback in Fancy Login 3.0.x

Same name and namespace in other branches
  1. 8.2 fancy_login.module \fancy_login_user_pass_ajax_callback()
  2. 7.3 fancy_login.module \fancy_login_user_pass_ajax_callback()

Ajax callback function for fancy_login_user_pass submit button.

1 string reference to 'fancy_login_user_pass_ajax_callback'
fancy_login_form_alter in ./fancy_login.module
Implements hook_form_alter().

File

./fancy_login.module, line 58
Holds hooks for the Fancy Login module.

Code

function fancy_login_user_pass_ajax_callback(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $message_data = drupal_get_messages(NULL, FALSE);

  // Check to see if there were any errors with the form submission.
  if (!count($message_data['error'])) {
    $response
      ->addCommand(new FancyLoginClosePopupCommand());
  }
  $renderer = \Drupal::service('renderer');
  $messages = [
    '#type' => 'status_messages',
  ];
  $messages = $renderer
    ->renderRoot($messages);
  $selector = '#fancy_login_user_pass_block_wrapper';
  $response
    ->addCommand(new AppendCommand($selector, $messages));
  return $response;
}