Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
Overrides PluginBase::submitOptionsForm
public function submitOptionsForm(&$form, &$form_state) {
// Not sure I like this being here, but it seems (?) like a logical place.
$cache_plugin = $this
->getPlugin('cache');
if ($cache_plugin) {
$cache_plugin
->cache_flush();
}
$section = $form_state['section'];
switch ($section) {
case 'display_id':
if (isset($form_state['values']['display_id'])) {
$this->display['new_id'] = $form_state['values']['display_id'];
}
break;
case 'display_title':
$this->display['display_title'] = $form_state['values']['display_title'];
$this
->setOption('display_description', $form_state['values']['display_description']);
break;
case 'access':
$access = $this
->getOption('access');
if ($access['type'] != $form_state['values']['access']['type']) {
$plugin = views_get_plugin('access', $form_state['values']['access']['type']);
if ($plugin) {
$access = array(
'type' => $form_state['values']['access']['type'],
);
$this
->setOption('access', $access);
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'access_options',
));
}
}
}
break;
case 'access_options':
$plugin = $this
->getPlugin('access');
if ($plugin) {
$access = $this
->getOption('access');
$plugin
->submitOptionsForm($form['access_options'], $form_state);
$access['options'] = $form_state['values'][$section];
$this
->setOption('access', $access);
}
break;
case 'cache':
$cache = $this
->getOption('cache');
if ($cache['type'] != $form_state['values']['cache']['type']) {
$plugin = views_get_plugin('cache', $form_state['values']['cache']['type']);
if ($plugin) {
$cache = array(
'type' => $form_state['values']['cache']['type'],
);
$this
->setOption('cache', $cache);
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'cache_options',
));
}
}
}
break;
case 'cache_options':
$plugin = $this
->getPlugin('cache');
if ($plugin) {
$cache = $this
->getOption('cache');
$plugin
->submitOptionsForm($form['cache_options'], $form_state);
$cache['options'] = $form_state['values'][$section];
$this
->setOption('cache', $cache);
}
break;
case 'query':
$plugin = $this
->getPlugin('query');
if ($plugin) {
$plugin
->submitOptionsForm($form['query']['options'], $form_state);
$this
->setOption('query', $form_state['values'][$section]);
}
break;
case 'link_display':
$this
->setOption('link_url', $form_state['values']['link_url']);
case 'title':
case 'css_class':
case 'display_comment':
$this
->setOption($section, $form_state['values'][$section]);
break;
case 'field_language':
$this
->setOption('field_langcode', $form_state['values']['field_langcode']);
$this
->setOption('field_langcode_add_to_query', $form_state['values']['field_langcode_add_to_query']);
break;
case 'use_ajax':
case 'hide_attachment_summary':
case 'hide_admin_links':
$this
->setOption($section, (bool) $form_state['values'][$section]);
break;
case 'use_more':
$this
->setOption($section, intval($form_state['values'][$section]));
$this
->setOption('use_more_always', !intval($form_state['values']['use_more_always']));
$this
->setOption('use_more_text', $form_state['values']['use_more_text']);
case 'distinct':
$this
->setOption($section, $form_state['values'][$section]);
break;
case 'group_by':
$this
->setOption($section, $form_state['values'][$section]);
break;
case 'row':
// This if prevents resetting options to default if they don't change
// the plugin.
$row = $this
->getOption('row');
if ($row['type'] != $form_state['values'][$section]) {
$plugin = views_get_plugin('row', $form_state['values'][$section]);
if ($plugin) {
$row = array(
'type' => $form_state['values'][$section],
);
$this
->setOption($section, $row);
// send ajax form to options page if we use it.
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'row_options',
));
}
}
}
break;
case 'style':
// This if prevents resetting options to default if they don't change
// the plugin.
$style = $this
->getOption('style');
if ($style['type'] != $form_state['values'][$section]) {
$plugin = views_get_plugin('style', $form_state['values'][$section]);
if ($plugin) {
$row = array(
'type' => $form_state['values'][$section],
);
$this
->setOption($section, $row);
// send ajax form to options page if we use it.
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'style_options',
));
}
}
}
break;
case 'style_options':
$plugin = $this
->getPlugin('style');
if ($plugin) {
$style = $this
->getOption('style');
$plugin
->submitOptionsForm($form['style_options'], $form_state);
$style['options'] = $form_state['values'][$section];
$this
->setOption('style', $style);
}
break;
case 'row_options':
$plugin = $this
->getPlugin('row');
if ($plugin) {
$row = $this
->getOption('row');
$plugin
->submitOptionsForm($form['row_options'], $form_state);
$row['options'] = $form_state['values'][$section];
$this
->setOption('row', $row);
}
break;
case 'exposed_block':
$this
->setOption($section, (bool) $form_state['values'][$section]);
break;
case 'exposed_form':
$exposed_form = $this
->getOption('exposed_form');
if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) {
$plugin = views_get_plugin('exposed_form', $form_state['values']['exposed_form']['type']);
if ($plugin) {
$exposed_form = array(
'type' => $form_state['values']['exposed_form']['type'],
'options' => array(),
);
$this
->setOption('exposed_form', $exposed_form);
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'exposed_form_options',
));
}
}
}
break;
case 'exposed_form_options':
$plugin = $this
->getPlugin('exposed_form');
if ($plugin) {
$exposed_form = $this
->getOption('exposed_form');
$plugin
->submitOptionsForm($form['exposed_form_options'], $form_state);
$exposed_form['options'] = $form_state['values'][$section];
$this
->setOption('exposed_form', $exposed_form);
}
break;
case 'pager':
$pager = $this
->getOption('pager');
if ($pager['type'] != $form_state['values']['pager']['type']) {
$plugin = views_get_plugin('pager', $form_state['values']['pager']['type']);
if ($plugin) {
// Because pagers have very similar options, let's allow pagers to
// try to carry the options over.
$plugin
->init($this->view, $this->display, $pager['options']);
$pager = array(
'type' => $form_state['values']['pager']['type'],
'options' => $plugin->options,
);
$this
->setOption('pager', $pager);
if ($plugin
->usesOptions()) {
$form_state['view']
->addFormToStack('display', $this->display['id'], array(
'pager_options',
));
}
}
}
break;
case 'pager_options':
$plugin = $this
->getPlugin('pager');
if ($plugin) {
$pager = $this
->getOption('pager');
$plugin
->submitOptionsForm($form['pager_options'], $form_state);
$pager['options'] = $form_state['values'][$section];
$this
->setOption('pager', $pager);
}
break;
}
foreach ($this->extender as $extender) {
$extender
->submitOptionsForm($form, $form_state);
}
}