You are here

function views_ui_add_item_form_submit in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 includes/admin.inc \views_ui_add_item_form_submit()
  2. 7.3 includes/admin.inc \views_ui_add_item_form_submit()

Submit handler for adding new item(s) to a view.

File

includes/admin.inc, line 2353
admin.inc Provides the Views' administrative interface.

Code

function views_ui_add_item_form_submit($form, &$form_state) {
  $type = $form_state['type'];
  $types = views_object_types();
  if (!empty($form_state['values']['name']) && is_array($form_state['values']['name'])) {

    // Loop through each of the items that were checked and add them to the view.
    foreach (array_keys(array_filter($form_state['values']['name'])) as $field) {
      list($table, $field) = explode('.', $field, 2);
      $id = $form_state['view']
        ->add_item($form_state['display_id'], $type, $table, $field);

      // check to see if this type has settings, if so add the settings form first
      $handler = views_get_handler($table, $field, $type);
      if ($handler && $handler
        ->has_extra_options()) {
        views_ui_add_form_to_stack('config-item-extra', $form_state['view'], $form_state['display_id'], array(
          $type,
          $id,
        ));
      }

      // Then add the form to the stack
      views_ui_add_form_to_stack('config-item', $form_state['view'], $form_state['display_id'], array(
        $type,
        $id,
      ));
    }
  }

  // Store in cache
  views_ui_cache_set($form_state['view']);
}