diff --git a/includes/field_ui.inc b/includes/field_ui.inc index dafe2df..a99afe9 100644 --- a/includes/field_ui.inc +++ b/includes/field_ui.inc @@ -272,10 +272,10 @@ function ds_field_ui_row_region(array $row) { */ function ds_field_ui_layouts_validate($form, FormStateInterface $form_state) { // Determine layout variables. - $layout = $form_state->getValue('layout'); + $layout = $form_state->getValue('ds_layout'); if ($layout === '_none') { $layout = ''; - $form_state->setValue('layout', ''); + $form_state->setValue('ds_layout', ''); } $old_layout = $form_state->getValue('old_layout'); $new_layout = ($layout != $old_layout) || empty($old_layout); @@ -283,7 +283,7 @@ function ds_field_ui_layouts_validate($form, FormStateInterface $form_state) { // 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('layout'), []); + $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'])) { @@ -326,7 +326,7 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { $view_mode = $display->getMode(); // Determine layout variables. - $layout = $form_state->getValue('layout'); + $layout = $form_state->getValue('ds_layout'); $disable_css = $form_state->getValue('disable_css'); $entity_classes = $form_state->getValue('entity_classes'); if (empty($entity_classes)) { @@ -367,8 +367,10 @@ function ds_field_ui_layouts_save($form, FormStateInterface $form_state) { $display->unsetThirdPartySetting('ds', 'fields'); $fields = $form_state->getValue('fields'); - foreach (array_keys($display->getComponents()) as $name) { - $fields[$name]['region'] = NULL; + if (!empty($fields)) { + foreach (array_keys($display->getComponents()) as $name) { + $fields[$name]['region'] = NULL; + } } $form_state->setValue('fields', $fields); } @@ -793,7 +795,7 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, array &$f } } - // If anything is left, then we put it on it's own vertial tab. + // If anything is left, then we put it on it's own vertical tab. if (!Element::isEmpty($layout_configuration_form)) { $form['layout_configuration'] = array_merge($layout_configuration_form, [ '#group' => 'additional_settings', @@ -872,7 +874,7 @@ function _ds_field_ui_table_layouts($entity_type, $bundle, $view_mode, array &$f function _ds_field_ui_table_layouts_preview(array &$form, FormStateInterface $form_state, array $ds_layouts, array $layout, EntityViewDisplayInterface $display) { $layout_string = ''; - $form['ds_layouts']['layout'] = [ + $form['ds_layouts']['ds_layout'] = [ '#type' => 'select', '#title' => t('Select a layout'), '#options' => $layout['layout_options'], @@ -886,7 +888,7 @@ function _ds_field_ui_table_layouts_preview(array &$form, FormStateInterface $fo ]; if (!isset($layout['layout'])) { - $form['ds_layouts']['layout']['#description'] = t("A layout must be selected to enable Display Suite functionality."); + $form['ds_layouts']['ds_layout']['#description'] = t("A layout must be selected to enable Display Suite functionality."); } $form['ds_layouts']['preview'] = [ @@ -896,8 +898,8 @@ function _ds_field_ui_table_layouts_preview(array &$form, FormStateInterface $fo '#weight' => -3, ]; - if (isset($layout['layout']) || $form_state->hasValue('layout')) { - $layout_string = $form_state->hasValue('layout') ? $form_state->getValue('layout') : $layout['layout']; + if (isset($layout['layout']) || $form_state->hasValue('ds_layout')) { + $layout_string = $form_state->hasValue('ds_layout') ? $form_state->getValue('ds_layout') : $layout['layout']; } if (!empty($layout_string)) { @@ -922,9 +924,9 @@ function _ds_field_ui_table_layouts_preview(array &$form, FormStateInterface $fo $suggestions_array[$key] = $suggestion_replace . '.html.twig'; } - if ($form_state->hasValue('layout') || (!empty($layout) && isset($layout['regions']))) { + if ($form_state->hasValue('ds_layout') || (!empty($layout) && isset($layout['regions']))) { $fallback_image = drupal_get_path('module', 'ds') . '/images/preview.png'; - $current_layout = $form_state->hasValue('layout') && (!isset($layout->layout) || $form_state->getValue('layout') != $layout->layout) ? t('Current layout (after save)') : t('Current layout'); + $current_layout = $form_state->hasValue('ds_layout') && (!isset($layout->layout) || $form_state->getValue('ds_layout') != $layout->layout) ? t('Current layout (after save)') : t('Current layout'); $image = $chosen_layout->getIconPath(); if (empty($image)) { $image = $fallback_image; diff --git a/tests/src/Functional/BlockTest.php b/tests/src/Functional/BlockTest.php index 79dfd09..79b4d04 100644 --- a/tests/src/Functional/BlockTest.php +++ b/tests/src/Functional/BlockTest.php @@ -85,7 +85,7 @@ class BlockTest extends TestBase { // Change to a DS layout. $url = 'admin/structure/block/block-content/manage/basic/display'; - $edit = ['layout' => 'ds_2col']; + $edit = ['ds_layout' => 'ds_2col']; $this->drupalPostForm($url, $edit, t('Save'), []); $fields = [ diff --git a/tests/src/Functional/CloneTest.php b/tests/src/Functional/CloneTest.php index 68bbd30..e880640 100644 --- a/tests/src/Functional/CloneTest.php +++ b/tests/src/Functional/CloneTest.php @@ -44,7 +44,7 @@ class CloneTest extends TestBase { $this->assertSession()->pageTextContains('The layout has been cloned.'); // Check that this now also has the expected region layout. - $option_field = $this->assertSession()->optionExists('edit-layout', 'ds_2col_stacked'); + $option_field = $this->assertSession()->optionExists('edit-ds-layout', 'ds_2col_stacked'); $this->assertTrue($option_field->hasAttribute('selected')); } diff --git a/tests/src/Functional/DsFieldCacheTest.php b/tests/src/Functional/DsFieldCacheTest.php index 6aa3a83..faff1b0 100644 --- a/tests/src/Functional/DsFieldCacheTest.php +++ b/tests/src/Functional/DsFieldCacheTest.php @@ -33,7 +33,7 @@ class DsFieldCacheTest extends TestBase { 'fields[test_caching_field][region]' => 'left', 'fields[test_caching_field][label]' => 'above', ]; - $this->drupalPostForm('admin/structure/types/manage/article/display', ['layout' => 'ds_2col'], t('Save')); + $this->drupalPostForm('admin/structure/types/manage/article/display', ['ds_layout' => 'ds_2col'], t('Save')); $this->dsConfigureUi($fields); // Create and visit the node so that it is cached as empty, ensure the title diff --git a/tests/src/Functional/DsTestTrait.php b/tests/src/Functional/DsTestTrait.php index 8dab2bd..c8532aa 100644 --- a/tests/src/Functional/DsTestTrait.php +++ b/tests/src/Functional/DsTestTrait.php @@ -12,7 +12,7 @@ trait DsTestTrait { */ public function dsSelectLayout($edit = [], $assert = [], $url = 'admin/structure/types/manage/article/display', $options = []) { $edit += [ - 'layout' => 'ds_2col_stacked', + 'ds_layout' => 'ds_2col_stacked', ]; $this->drupalPostForm($url, $edit, t('Save'), $options); diff --git a/tests/src/Functional/EntitiesTest.php b/tests/src/Functional/EntitiesTest.php index da94cf2..6819a2b 100644 --- a/tests/src/Functional/EntitiesTest.php +++ b/tests/src/Functional/EntitiesTest.php @@ -78,7 +78,7 @@ class EntitiesTest extends TestBase { // Configure teaser layout. $teaser = [ - 'layout' => 'ds_2col', + 'ds_layout' => 'ds_2col', ]; $teaser_assert = [ 'regions' => [ @@ -138,7 +138,7 @@ class EntitiesTest extends TestBase { // Select layout and configure fields. $edit = [ - 'layout' => 'ds_2col', + 'ds_layout' => 'ds_2col', ]; $assert = [ 'regions' => [ @@ -221,7 +221,7 @@ class EntitiesTest extends TestBase { // Convert layout from test theme. // Configure teaser layout. $test_theme_template = [ - 'layout' => 'ds_test_layout_theme', + 'ds_layout' => 'ds_test_layout_theme', ]; $test_theme_template_assert = [ 'regions' => [ diff --git a/tests/src/Functional/ExportablesTest.php b/tests/src/Functional/ExportablesTest.php index 3680532..88c32bd 100644 --- a/tests/src/Functional/ExportablesTest.php +++ b/tests/src/Functional/ExportablesTest.php @@ -54,7 +54,7 @@ class ExportablesTest extends TestBase { // Override default layout. $layout = [ - 'layout' => 'ds_2col_stacked', + 'ds_layout' => 'ds_2col_stacked', ]; $assert = [ diff --git a/tests/src/Functional/FieldGroupTest.php b/tests/src/Functional/FieldGroupTest.php index df2d03b..44fb992 100644 --- a/tests/src/Functional/FieldGroupTest.php +++ b/tests/src/Functional/FieldGroupTest.php @@ -28,7 +28,7 @@ class FieldGroupTest extends TestBase { // Configure layout. $layout = [ - 'layout' => 'ds_2col', + 'ds_layout' => 'ds_2col', ]; $layout_assert = [ 'regions' => [ diff --git a/tests/src/Functional/FieldPluginTest.php b/tests/src/Functional/FieldPluginTest.php index 54b54d1..78a8552 100644 --- a/tests/src/Functional/FieldPluginTest.php +++ b/tests/src/Functional/FieldPluginTest.php @@ -28,7 +28,7 @@ class FieldPluginTest extends TestBase { $this->assertSession()->pageTextContains('Field altered'); $empty = []; - $edit = ['layout' => 'ds_2col_stacked']; + $edit = ['ds_layout' => 'ds_2col_stacked']; $this->dsSelectLayout($edit, $empty, 'admin/config/people/accounts/display'); // Fields can not be found on user. diff --git a/tests/src/Functional/LayoutClassesTest.php b/tests/src/Functional/LayoutClassesTest.php index 828c862..97ab9d0 100644 --- a/tests/src/Functional/LayoutClassesTest.php +++ b/tests/src/Functional/LayoutClassesTest.php @@ -41,7 +41,7 @@ class LayoutClassesTest extends TestBase { $this->dsCreateBlockField(); $layout = [ - 'layout' => 'ds_2col_stacked', + 'ds_layout' => 'ds_2col_stacked', ]; $assert = [ @@ -156,7 +156,7 @@ class LayoutClassesTest extends TestBase { // Select layout. $layout = [ - 'layout' => 'ds_2col', + 'ds_layout' => 'ds_2col', ]; $assert = [ @@ -216,7 +216,7 @@ class LayoutClassesTest extends TestBase { // Test that a default view mode with no layout is not affected by a // disabled view mode. $edit = [ - 'layout' => '_none', + 'ds_layout' => '_none', 'display_modes_custom[full]' => FALSE, ]; $this->drupalPostForm('admin/structure/types/manage/article/display', $edit,'Save'); diff --git a/tests/src/Functional/LayoutFluidTest.php b/tests/src/Functional/LayoutFluidTest.php index fd372bd..2cef150 100644 --- a/tests/src/Functional/LayoutFluidTest.php +++ b/tests/src/Functional/LayoutFluidTest.php @@ -18,7 +18,7 @@ class LayoutFluidTest extends TestBase { $this->assertSession()->responseContains('Test Fluid two column'); $layout = [ - 'layout' => 'dstest_2col_fluid', + 'ds_layout' => 'dstest_2col_fluid', ]; $assert = [ diff --git a/tests/src/Functional/LayoutPluginTest.php b/tests/src/Functional/LayoutPluginTest.php index aa5c761..fb41b73 100644 --- a/tests/src/Functional/LayoutPluginTest.php +++ b/tests/src/Functional/LayoutPluginTest.php @@ -19,7 +19,7 @@ class LayoutPluginTest extends TestBase { $this->assertSession()->responseContains('Test Two column'); $layout = [ - 'layout' => 'dstest_2col', + 'ds_layout' => 'dstest_2col', ]; $assert = [ @@ -62,7 +62,7 @@ class LayoutPluginTest extends TestBase { */ public function testResetLayout() { $layout = [ - 'layout' => 'ds_reset', + 'ds_layout' => 'ds_reset', ]; $assert = [ @@ -108,7 +108,7 @@ class LayoutPluginTest extends TestBase { 'ds_content' => '' . t('Content') . '', ], ]; - $this->dsSelectLayout(['layout' => 'ds_1col'], $assert); + $this->dsSelectLayout(['ds_layout' => 'ds_1col'], $assert); // Go to the node. $this->drupalGet('node/' . $node->id()); diff --git a/tests/src/Functional/TestBase.php b/tests/src/Functional/TestBase.php index 9e717c8..21bea90 100644 --- a/tests/src/Functional/TestBase.php +++ b/tests/src/Functional/TestBase.php @@ -38,6 +38,7 @@ abstract class TestBase extends BrowserTestBase { 'ds', 'ds_extras', 'ds_test', + 'layout_builder', 'ds_switch_view_mode', 'layout_discovery', 'field_group', diff --git a/tests/src/Functional/TwigRenderTest.php b/tests/src/Functional/TwigRenderTest.php index 475b203..b3c6c88 100644 --- a/tests/src/Functional/TwigRenderTest.php +++ b/tests/src/Functional/TwigRenderTest.php @@ -20,7 +20,7 @@ class TwigRenderTest extends TestBase { // Configure layout. $layout = [ - 'layout' => 'dstest_1col_title', + 'ds_layout' => 'dstest_1col_title', ]; $layout_assert = [ 'regions' => [ diff --git a/tests/src/Functional/ViewsTest.php b/tests/src/Functional/ViewsTest.php index 55d9efd..4a5a128 100644 --- a/tests/src/Functional/ViewsTest.php +++ b/tests/src/Functional/ViewsTest.php @@ -88,7 +88,7 @@ class ViewsTest extends TestBase { // Configure teaser and full layout. $layout = [ - 'layout' => 'ds_2col', + 'ds_layout' => 'ds_2col', ]; $fields = [ 'fields[node_title][region]' => 'left', @@ -103,7 +103,7 @@ class ViewsTest extends TestBase { $this->dsSelectLayout($layout, $assert, 'admin/structure/types/manage/article/display/teaser'); $this->dsConfigureUi($fields, 'admin/structure/types/manage/article/display/teaser'); $layout = [ - 'layout' => 'ds_4col', + 'ds_layout' => 'ds_4col', ]; $fields = [ 'fields[node_post_date][region]' => 'first', diff --git a/tests/src/FunctionalJavascript/JavascriptTest.php b/tests/src/FunctionalJavascript/JavascriptTest.php index c7fd88b..f70b237 100644 --- a/tests/src/FunctionalJavascript/JavascriptTest.php +++ b/tests/src/FunctionalJavascript/JavascriptTest.php @@ -65,7 +65,7 @@ class JavascriptTest extends JavascriptTestBase { // Change the layout to 2 column layout and wait for it to be changed, see // if the new template is displayed. - $page->selectFieldOption('layout', 'ds_2col'); + $page->selectFieldOption('ds_layout', 'ds_2col'); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('ds-2col--node.html.twig'); $page->pressButton('Save'); @@ -80,7 +80,7 @@ class JavascriptTest extends JavascriptTestBase { $this->assertSame($settings['id'], 'ds_2col'); // Switch back to not using a layout. - $page->selectFieldOption('layout', ''); + $page->selectFieldOption('ds_layout', ''); $this->assertSession()->assertWaitOnAjaxRequest(); $page->pressButton('Save');