You are here

function _ajax_register_add_ajax in Ajax Login/Register 7.4

Add form wrapper and #ajax attribute to forms.

1 call to _ajax_register_add_ajax()
ajax_register_form_alter in ./ajax_register.module
Implements hook_form_alter().

File

./ajax_register.module, line 230

Code

function _ajax_register_add_ajax(&$form, $type) {

  // Add ajax wrapper to form.
  $html_id = drupal_html_id('ajax-register-' . str_replace('_', '-', $type) . '-wrapper');
  $form['#theme_wrappers'][] = 'ajax_register_wrapper';

  // User login block and user login form have same ajax callback;
  if ($type == 'user_login_block') {
    $type = 'user_login';
  }

  // Add ajax functionality to form submit button.
  $form['actions']['submit']['#ajax'] = array(
    'callback' => 'ajax_register_' . $type . '_ajax_callback',
    'wrapper' => $html_id,
    'event' => 'click',
  );

  // Add ctools modal style.
  $form['actions']['submit']['#attributes']['class'][] = 'ctools-modal-ctools-ajax-register-style';
}