You are here

function entityqueue_field_widget_ajax_callback in Entityqueue 7

Ajax form callback.

2 string references to 'entityqueue_field_widget_ajax_callback'
entityqueue_field_widget_form in ./entityqueue.module
Implements hook_field_widget_form().
entityqueue_widget_dragtable_element_validate in ./entityqueue.module
Element validate callback.

File

./entityqueue.module, line 1198
Allows users to collect entities in arbitrarily ordered lists.

Code

function entityqueue_field_widget_ajax_callback($form, $form_state) {
  $field_name = $form_state['triggering_element']['#parents'][0];
  $lang = $form[$field_name]['#language'];
  $form_state['rebuild'] = TRUE;
  $form[$field_name][$lang]['add']['#value'] = '';
  $markup = theme('status_messages') . drupal_render($form[$field_name]);
  $commands[] = ajax_command_replace('.' . drupal_clean_css_identifier('field-name-' . $field_name), $markup);
  $add_id = drupal_clean_css_identifier('entityqueue-dragtable-' . $field_name . '-add');
  $commands[] = ajax_command_invoke('.' . $add_id, 'val', array(
    '',
  ));
  $settings = array(
    drupal_clean_css_identifier('entityqueue-dragtable-' . $field_name) => TRUE,
  );
  if (!empty($form_state['entityqueue_changed'])) {
    drupal_add_js(array(
      'entityqueue_changed' => $settings,
    ), 'setting');
  }
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}