function views_ui_change_style_form_submit

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

File

includes/admin.inc, line 3505

Code

function views_ui_change_style_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;
    $plugin = views_get_plugin('style', $form_state['values']['style_plugin']);
    if (!$plugin) {
        drupal_set_message(t('Internal error: broken plugin.'), 'error');
        return;
    }
    $plugin->init($form_state['view'], $form_state['view']->display[$form_state['display_id']]);
    // If changing style plugin, reset options to defaults.
    if (empty($item['style_plugin']) || $item['style_plugin'] != $form_state['values']['style_plugin']) {
        $item['style_options'] = $plugin->options;
    }
    // Store the data we're given.
    $item['style_plugin'] = $form_state['values']['style_plugin'];
    // Store the item back on the view
    $form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $item);
    if (!empty($plugin->definition['uses options'])) {
        views_ui_add_form_to_stack('config-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']);
}