function DisplayPluginBase::submitOptionsForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm()
- 10 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm()
Overrides PluginBase::submitOptionsForm
4 methods override DisplayPluginBase::submitOptionsForm()
- Attachment::submitOptionsForm in core/
modules/ views/ src/ Plugin/ views/ display/ Attachment.php - Perform any necessary changes to the form values prior to storage.
- Block::submitOptionsForm in core/
modules/ views/ src/ Plugin/ views/ display/ Block.php - Perform any necessary changes to the form values prior to storage.
- DisplayTest::submitOptionsForm in core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ display/ DisplayTest.php - Handle any special handling on the validate form.
- PathPluginBase::submitOptionsForm in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Handle any special handling on the validate form.
File
-
core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 1940
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function submitOptionsForm(&$form, FormStateInterface $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->cacheFlush();
}
$section = $form_state->get('section');
switch ($section) {
case 'display_id':
if ($form_state->hasValue('display_id')) {
$this->display['new_id'] = $form_state->getValue('display_id');
}
break;
case 'display_title':
$this->display['display_title'] = $form_state->getValue('display_title');
$this->setOption('display_description', $form_state->getValue('display_description'));
break;
case 'query':
$plugin = $this->getPlugin('query');
if ($plugin) {
$plugin->submitOptionsForm($form['query']['options'], $form_state);
$this->setOption('query', $form_state->getValue($section));
}
break;
case 'link_display':
$this->setOption('link_url', $form_state->getValue('link_url'));
case 'title':
case 'css_class':
case 'display_comment':
case 'distinct':
case 'group_by':
$this->setOption($section, $form_state->getValue($section));
break;
case 'rendering_language':
$this->setOption('rendering_language', $form_state->getValue('rendering_language'));
break;
case 'use_ajax':
case 'hide_attachment_summary':
case 'show_admin_links':
case 'exposed_block':
$this->setOption($section, (bool) $form_state->getValue($section));
break;
case 'use_more':
$this->setOption($section, intval($form_state->getValue($section)));
$this->setOption('use_more_always', intval($form_state->getValue('use_more_always')));
$this->setOption('use_more_text', $form_state->getValue('use_more_text'));
break;
case 'access':
case 'cache':
case 'exposed_form':
case 'pager':
case 'row':
case 'style':
$plugin_type = $section;
$plugin_options = $this->getOption($plugin_type);
$type = $form_state->getValue([
$plugin_type,
'type',
]);
if ($plugin_options['type'] != $type) {
/** @var \Drupal\views\Plugin\views\ViewsPluginInterface $plugin */
$plugin = Views::pluginManager($plugin_type)->createInstance($type);
if ($plugin) {
$plugin->init($this->view, $this, $plugin_options['options']);
$plugin_options = [
'type' => $type,
'options' => $plugin->options,
];
$plugin->filterByDefinedOptions($plugin_options['options']);
$this->setOption($plugin_type, $plugin_options);
if ($plugin->usesOptions()) {
$form_state->get('view')
->addFormToStack('display', $this->display['id'], $plugin_type . '_options');
}
}
}
break;
case 'access_options':
case 'cache_options':
case 'exposed_form_options':
case 'pager_options':
case 'row_options':
case 'style_options':
// Submit plugin options. Every section with "_options" in it, belongs to
// a plugin type, like "style_options".
$plugin_type = str_replace('_options', '', $section);
if ($plugin = $this->getPlugin($plugin_type)) {
$plugin_options = $this->getOption($plugin_type);
$plugin->submitOptionsForm($form[$plugin_type . '_options'], $form_state);
$plugin_options['options'] = $form_state->getValue($section);
$this->setOption($plugin_type, $plugin_options);
}
break;
}
$extender_options = $this->getOption('display_extenders');
foreach ($this->extenders as $extender) {
$extender->submitOptionsForm($form, $form_state);
$plugin_id = $extender->getPluginId();
$extender_options[$plugin_id] = $extender->options;
}
$this->setOption('display_extenders', $extender_options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.