function ds_field_ui_layouts_validate in Display Suite 8.3
Same name and namespace in other branches
- 8.4 includes/field_ui.inc \ds_field_ui_layouts_validate()
- 8.2 includes/field_ui.inc \ds_field_ui_layouts_validate()
- 7.2 includes/ds.field_ui.inc \ds_field_ui_layouts_validate()
- 7 ds.field_ui.inc \ds_field_ui_layouts_validate()
Validate the layout settings on the Field UI.
1 string reference to 'ds_field_ui_layouts_validate'
- _ds_field_ui_table_layouts in includes/
field_ui.inc - Add the layouts fieldset on the Field UI screen.
File
- includes/
field_ui.inc, line 282 - Field UI functions for Display Suite.
Code
function ds_field_ui_layouts_validate($form, FormStateInterface $form_state) {
// Determine layout variables.
$layout = $form_state
->getValue('ds_layout');
if ($layout === '_none') {
$layout = '';
$form_state
->setValue('ds_layout', '');
}
$old_layout = $form_state
->getValue('old_layout');
$new_layout = $layout != $old_layout || empty($old_layout);
// Only validate the layout settings if the layout hasn't changed.
if (!$new_layout && !empty($layout)) {
/* @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout_plugin */
$layout_plugin = \Drupal::service('plugin.manager.core.layout')
->createInstance($form_state
->getValue('ds_layout'), []);
$layout_form = isset($form['layout_configuration']) ? $form['layout_configuration'] : [];
foreach (Element::children($form) as $name) {
if (!empty($form[$name]['#ds_layout_configuration'])) {
$layout_form[$name] = $form[$name];
}
}
if ($layout_plugin instanceof PluginFormInterface) {
$layout_form_state = (new FormState())
->setValues($form_state
->getValue('layout_configuration', []));
// TODO
//$layout_plugin->validateConfigurationForm($layout_form, $layout_form_state);
}
}
// Move the view modes so Field UI can handle them.
if ($form_state
->hasValue('modes')) {
$modes = $form_state
->getValue('modes');
if (isset($modes['display_modes_custom'])) {
$form_state
->setValue('display_modes_custom', $modes['display_modes_custom']);
}
}
}