You are here

function entityqueue_subqueue_edit_form in Entityqueue 7

Form callback; Displays the subqueue edit form.

2 string references to 'entityqueue_subqueue_edit_form'
entityqueue_export_ui::subqueue_add_page in plugins/ctools/export_ui/entityqueue_export_ui.class.php
Page callback; Displays the subqueue add form.
entityqueue_export_ui::subqueue_edit_page in plugins/ctools/export_ui/entityqueue_export_ui.class.php
Page callback; Displays the subqueue edit form.

File

includes/entityqueue.admin.inc, line 24
Administrative pages for Entity Queue.

Code

function entityqueue_subqueue_edit_form($form, &$form_state, EntityQueue $queue, EntitySubqueue $subqueue) {

  // When called using #ajax via ajax_form_callback(), 'export' may
  // not be included so include it here.
  _entityqueue_subqueue_add_form_files($form, $form_state);
  $handler = entityqueue_get_handler($queue);
  $form = $handler
    ->subqueueForm($subqueue, $form_state);
  $form_state['entityqueue_queue'] = $queue;
  $form_state['entityqueue_subqueue'] = $subqueue;
  field_attach_form('entityqueue_subqueue', $subqueue, $form, $form_state);

  // Since the form has ajax buttons, the $wrapper_id will change each time
  // one of those buttons is clicked. Therefore the whole form has to be
  // replaced, otherwise the buttons will have the old $wrapper_id and will only
  // work on the first click.
  $field_name = _entityqueue_get_target_field_name($queue->target_type);
  if (isset($form_state['form_wrapper_id'])) {
    $wrapper_id = $form_state['form_wrapper_id'];
  }
  else {
    $wrapper_id = drupal_html_id($field_name . '-wrapper');
  }
  $form_state['form_wrapper_id'] = $wrapper_id;
  $form_state['field_name'] = $field_name;
  $form['#prefix'] = '<div id="' . $wrapper_id . '">';
  $form['#suffix'] = '</div>';

  // Entity type (bundle) is needed by entity_form_submit_build_entity().
  $form['queue'] = array(
    '#type' => 'value',
    '#default_value' => $queue->name,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 40,
  );
  $form['actions']['reverse'] = array(
    '#type' => 'button',
    '#value' => t('Reverse'),
    '#weight' => 41,
    '#validate' => array(
      'entityqueue_subqueue_reverse_validate',
    ),
    '#ajax' => array(
      'callback' => 'entityqueue_subqueue_ajax_callback',
      'wrapper' => $wrapper_id,
    ),
  );
  $form['actions']['shuffle'] = array(
    '#type' => 'button',
    '#value' => t('Shuffle'),
    '#weight' => 42,
    '#validate' => array(
      'entityqueue_subqueue_shuffle_validate',
    ),
    '#ajax' => array(
      'callback' => 'entityqueue_subqueue_ajax_callback',
      'wrapper' => $wrapper_id,
    ),
  );
  $form['actions']['clear'] = array(
    '#type' => 'button',
    '#value' => t('Clear'),
    '#weight' => 43,
    '#validate' => array(
      'entityqueue_subqueue_clear_validate',
    ),
    '#ajax' => array(
      'callback' => 'entityqueue_subqueue_ajax_callback',
      'wrapper' => $wrapper_id,
    ),
  );
  $form['#validate'][] = 'entityqueue_subqueue_edit_form_validate';
  $form['#submit'][] = 'entityqueue_subqueue_edit_form_submit';
  return $form;
}