function ConfigHandler::submitForm
Same name in other branches
- 9 core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::submitForm()
- 8.9.x core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::submitForm()
- 11.x core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::submitForm()
Overrides ViewsFormBase::submitForm
File
-
core/
modules/ views_ui/ src/ Form/ Ajax/ ConfigHandler.php, line 204
Class
- ConfigHandler
- Provides a form for configuring an item in the Views UI.
Namespace
Drupal\views_ui\Form\AjaxCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$view = $form_state->get('view');
$display_id = $form_state->get('display_id');
$id = $form_state->get('id');
$handler = $form_state->get('handler');
// Run it through the handler's submit function.
$handler->submitOptionsForm($form['options'], $form_state);
$item = $handler->options;
$types = ViewExecutable::getHandlerTypes();
// For footer/header $handler_type is area but $type is footer/header.
// For all other handle types it's the same.
$handler_type = $type = $form_state->get('type');
if (!empty($types[$type]['type'])) {
$handler_type = $types[$type]['type'];
}
$override = NULL;
$executable = $view->getExecutable();
if ($executable->display_handler
->useGroupBy() && !empty($item['group_type'])) {
if (empty($executable->query)) {
$executable->initQuery();
}
$aggregate = $executable->query
->getAggregationInfo();
if (!empty($aggregate[$item['group_type']]['handler'][$type])) {
$override = $aggregate[$item['group_type']]['handler'][$type];
}
}
// Create a new handler and unpack the options from the form onto it. We
// can use that for storage.
$handler = Views::handlerManager($handler_type)->getHandler($item, $override);
$handler->init($executable, $executable->display_handler, $item);
// Add the incoming options to existing options because items using
// the extra form may not have everything in the form here.
$options = $handler->submitFormCalculateOptions($handler->options, $form_state->getValue('options', []));
// This unpacks only options that are in the definition, ensuring random
// extra stuff on the form is not sent through.
$handler->unpackOptions($handler->options, $options, NULL, FALSE);
// Store the item back on the view
$executable->setHandler($display_id, $type, $id, $handler->options);
// Ensure any temporary options are removed.
if (isset($view->temporary_options[$type][$id])) {
unset($view->temporary_options[$type][$id]);
}
// Write to cache
$view->cacheSet();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.