public function LayoutChangeSettings::submitForm in Panels 8.4
Same name and namespace in other branches
- 8.3 src/Form/LayoutChangeSettings.php \Drupal\panels\Form\LayoutChangeSettings::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ LayoutChangeSettings.php, line 115
Class
- LayoutChangeSettings
- Provides a form for configuring a layout's settings.
Namespace
Drupal\panels\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/** @var \Drupal\ctools\Wizard\EntityFormWizardInterface $wizard */
$wizard = $form_state
->getFormObject();
$next_params = $wizard
->getNextParameters($cached_values);
/* @var $plugin \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant */
$plugin = $cached_values['plugin'];
$layout_id = !empty($cached_values['layout_change']['new_layout']) ? $cached_values['layout_change']['new_layout'] : $plugin
->getConfiguration()['layout'];
/** @var \Drupal\Core\Layout\LayoutInterface $layout */
$layout = $this->manager
->createInstance($layout_id, []);
// If we're dealing with a form, submit it.
if ($layout instanceof PluginFormInterface) {
$sub_form_state = new FormState();
$plugin_values = $form_state
->getValue([
'layout_settings_wrapper',
'layout_settings',
]);
// If form values came through the step's submission, handle them.
if ($plugin_values) {
$sub_form_state
->setValues($plugin_values);
$layout
->submitConfigurationForm($form, $sub_form_state);
// If this plugin is configurable, get that configuration and set it in
// cached values.
if (PluginHelper::isConfigurable($layout)) {
$cached_values = $this
->setCachedValues($next_params['step'], $plugin, $layout, $cached_values, $layout
->getConfiguration());
}
}
else {
$cached_values = $this
->setCachedValues($next_params['step'], $plugin, $layout, $cached_values, []);
}
}
else {
$cached_values = $this
->setCachedValues($next_params['step'], $plugin, $layout, $cached_values, []);
}
$form_state
->setTemporaryValue('wizard', $cached_values);
}