function views_ui_config_item_form_submit

Same name in other branches
  1. 7.x-3.x includes/admin.inc \views_ui_config_item_form_submit()

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

File

includes/admin.inc, line 3252

Code

function views_ui_config_item_form_submit($form, &$form_state) {
    // Run it through the handler's submit function.
    $form_state['handler']->options_submit($form['options'], $form_state);
    $item = $form_state['handler']->options;
    $types = views_object_types();
    $type = $form_state['type'];
    if (!empty($types[$type]['type'])) {
        $type = $types[$type]['type'];
    }
    // Create a new handler and unpack the options from the form onto it. We
    // can use that for storage.
    $handler = views_get_handler($item['table'], $item['field'], $type);
    $handler->init($form_state['view'], $item);
    // Add the incoming options to existing options because items using
    // the extra form may not have everything in the form here.
    $options = $form_state['values']['options'] + $form_state['handler']->options;
    // This unpacks only options that are in the definition, ensuring random
    // extra stuff on the form is not sent through.
    $handler->unpack_options($handler->options, $options, NULL, FALSE);
    // Store the item back on the view
    $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $handler->options);
    if ($form_state['handler'] && $form_state['handler']->needs_style_plugin()) {
        views_ui_add_form_to_stack('change-style', $form_state['view'], $form_state['display_id'], array(
            $form_state['type'],
            $form_state['id'],
        ), TRUE);
    }
    // Write to cache
    views_ui_cache_set($form_state['view']);
}