You are here

function username_check_form_user_form_alter in Username originality AJAX check 8

File

./username_check.module, line 32
Checks user name availability on registration page.

Code

function username_check_form_user_form_alter(&$form) {
  global $base_url;
  $module_path = drupal_get_path('module', 'username_check');
  $config = \Drupal::config('username_check.settings');
  $mode = $config
    ->get('username_check_mode');
  $delay = $config
    ->get('username_check_delay');
  if ($mode != 'off') {
    $form['#attached']['library'] = array(
      'username_check/username_check',
    );
    $form['#attached']['drupalSettings']['profileCheck']['ajaxUrl'] = $base_url . '/username_check/isuniqueprofile';
    $form['#attached']['drupalSettings']['profileCheck']['delay'] = $delay;
    $form['account']['name']['#field_suffix'] = '<span id="profile-check-informer">&nbsp;</span>';
    $form['account']['name']['#suffix'] = '<div id="profile-check-message"></div>';
  }
}