You are here

function submitSelectForm in Entity Embed 7.2

Same name and namespace in other branches
  1. 7.3 entity_embed.admin.inc \submitSelectForm()
  2. 7 entity_embed.admin.inc \submitSelectForm()

Form submission handler that selects an entity and display embed settings.

Parameters

$form: An associative array containing the structure of the form.

$form_state: An associative array containing the current state of the form.

1 string reference to 'submitSelectForm'
entity_embed_dialog_form in ./entity_embed.admin.inc
Form constructor for the entity embed dialog form.

File

./entity_embed.admin.inc, line 383
Admin page callbacks for the entity_embed module.

Code

function submitSelectForm(&$form, $form_state) {

  // Display errors in form, if any.
  if (form_get_errors()) {
    unset($form['#prefix'], $form['#suffix']);
    $status_messages = array(
      '#theme' => 'status_messages',
    );
    $output = drupal_render($form);
    $output = '<div>' . drupal_render($status_messages) . $output . '</div>';
    $commands[] = ajax_command_html('#entity-embed-dialog-form', $output);
  }
  else {
    $form_state['step'] = 'embed';
    $form_state['rebuild'] = TRUE;
    $rebuild_form = drupal_rebuild_form('entity_embed_dialog_form', $form_state, $form);
    unset($rebuild_form['#prefix'], $rebuild_form['#suffix']);
    $status_messages = array(
      '#theme' => 'status_messages',
    );
    $output = drupal_render($rebuild_form);
    drupal_process_attached($rebuild_form);
    $output = '<div>' . drupal_render($status_messages) . $output . '</div>';
    $commands[] = ajax_command_html('#entity-embed-dialog-form', $output);
  }
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}