You are here

function mobile_number_verify_ajax in Mobile Number 7

Mobile element ajax callback.

1 string reference to 'mobile_number_verify_ajax'
mobile_number_element_process in ./mobile_number.module
Mobile number element process callback.

File

./mobile_number.module, line 1063
mobile_number.module

Code

function mobile_number_verify_ajax($form, &$form_state) {
  drupal_get_messages();
  $parents = $form_state['triggering_element']['#array_parents'];
  $tree_parents = $form_state['triggering_element']['#parents'];
  array_pop($parents);
  array_pop($tree_parents);
  $element = drupal_array_get_nested_value($form, $parents);
  $field_name = $element['#name'];
  $field_path = implode('][', $tree_parents);
  $errors = !empty($form_state['storage']['mobile_number_fields'][$field_path]['errors']) ? $form_state['storage']['mobile_number_fields'][$field_path]['errors'] : array();
  foreach ($errors as $field => $error) {
    drupal_set_message($error, 'error');
    unset($errors[$field]);
  }
  $element['messages'] = array(
    '#markup' => theme('status_messages'),
  );
  unset($element['_weight']);
  $commands = array();
  $commands[] = ajax_command_replace(NULL, render($element));
  if (!empty($form_state['storage']['mobileNumberVerificationPrompt'][$field_path])) {
    $commands[] = ajax_command_settings(array(
      'mobileNumberVerificationPrompt' => $element['#id'],
    ));
  }
  if (!empty($form_state['storage']['mobileNumberVerified'][$field_path])) {
    $commands[] = ajax_command_settings(array(
      'mobileNumberVerified' => $element['#id'],
    ));
  }
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}