+
{{ content.left }}
-
diff --git a/core/modules/field_layout/layouts/twocol/twocol.layout.css b/core/modules/field_layout/layouts/twocol/twocol.layout.css
index 8e2f623..78a447d 100644
--- a/core/modules/field_layout/layouts/twocol/twocol.layout.css
+++ b/core/modules/field_layout/layouts/twocol/twocol.layout.css
@@ -1,14 +1,14 @@
-.field-layout--twocol {
+.layout--twocol {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
-.field-layout--twocol > .field-layout-region {
+.layout--twocol > .layout-region {
flex: 0 1 50%;
max-width: 50%;
}
-.field-layout--twocol > .field-layout-region--left {
+.layout--twocol > .layout-region--left {
max-width: calc(50% - 10px);
margin-right: 10px;
}
diff --git a/core/modules/field_layout/src/Display/EntityDisplayWithLayoutInterface.php b/core/modules/field_layout/src/Display/EntityDisplayWithLayoutInterface.php
index 54a2d52..3bee65e 100644
--- a/core/modules/field_layout/src/Display/EntityDisplayWithLayoutInterface.php
+++ b/core/modules/field_layout/src/Display/EntityDisplayWithLayoutInterface.php
@@ -64,4 +64,15 @@ public function setLayout(LayoutInterface $layout);
*/
public function getLayout();
+ /**
+ * Ensures this entity has a layout.
+ *
+ * @param string $default_layout_id
+ * (optional) The layout ID to use as a default. Defaults to
+ * 'layout_onecol'.
+ *
+ * @return $this
+ */
+ public function ensureLayout($default_layout_id = 'layout_onecol');
+
}
diff --git a/core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php b/core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php
index 0b4e01c..8d89d21 100644
--- a/core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php
+++ b/core/modules/field_layout/src/Entity/FieldLayoutEntityDisplayTrait.php
@@ -77,31 +77,21 @@ protected function init() {
* Overrides \Drupal\Core\Entity\EntityDisplayBase::preSave().
*/
public function preSave(EntityStorageInterface $storage) {
- if (!\Drupal::state()->get('field_layout_being_uninstalled')) {
- $this->ensureLayout();
- }
-
parent::preSave($storage);
// Ensure the plugin configuration is updated. Once layouts are no longer
// stored as third party settings, this will be handled by the code in
// \Drupal\Core\Config\Entity\ConfigEntityBase::preSave() that handles
// \Drupal\Core\Entity\EntityWithPluginCollectionInterface.
- if (!\Drupal::state()->get('field_layout_being_uninstalled')) {
+ if ($this->getLayoutId()) {
$this->setLayout($this->getLayout());
}
}
/**
- * Ensures this entity has a layout.
- *
- * @param string $default_layout_id
- * (optional) The layout ID to use as a default. Defaults to
- * 'field_layout_onecol'.
- *
- * @return $this
+ * {@inheritdoc}
*/
- protected function ensureLayout($default_layout_id = 'field_layout_onecol') {
+ public function ensureLayout($default_layout_id = 'layout_onecol') {
if (!$this->getLayoutId()) {
$this->setLayoutId($default_layout_id);
}
diff --git a/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php b/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php
index e54fa5b..683ccd2 100644
--- a/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php
+++ b/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php
@@ -49,8 +49,8 @@ protected function setUp() {
public function testNodeView() {
// By default, the one-column layout is used.
$this->drupalGet('node/1');
- $this->assertSession()->elementExists('css', '.field-layout--onecol');
- $this->assertSession()->elementExists('css', '.field-layout-region--content .field--name-body');
+ $this->assertSession()->elementExists('css', '.layout--onecol');
+ $this->assertSession()->elementExists('css', '.layout-region--content .field--name-body');
$this->drupalGet('admin/structure/types/manage/article/display');
$this->assertEquals(['Content', 'Disabled'], $this->getRegionTitles());
diff --git a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
index 0953278..46ab6c2 100644
--- a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
+++ b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
@@ -47,9 +47,9 @@ protected function setUp() {
public function testEntityViewModes() {
// By default, the field is not visible.
$this->drupalGet('entity_test/1/test');
- $this->assertSession()->elementNotExists('css', '.field-layout-region--content .field--name-field-test-text');
+ $this->assertSession()->elementNotExists('css', '.layout-region--content .field--name-field-test-text');
$this->drupalGet('entity_test/1');
- $this->assertSession()->elementNotExists('css', '.field-layout-region--content .field--name-field-test-text');
+ $this->assertSession()->elementNotExists('css', '.layout-region--content .field--name-field-test-text');
// Change the layout for the "test" view mode. See
// core.entity_view_mode.entity_test.test.yml.
@@ -65,9 +65,9 @@ public function testEntityViewModes() {
// Each view mode has a different layout.
$this->drupalGet('entity_test/1/test');
- $this->assertSession()->elementExists('css', '.field-layout-region--content .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout-region--content .field--name-field-test-text');
$this->drupalGet('entity_test/1');
- $this->assertSession()->elementNotExists('css', '.field-layout-region--content .field--name-field-test-text');
+ $this->assertSession()->elementNotExists('css', '.layout-region--content .field--name-field-test-text');
}
/**
@@ -84,7 +84,7 @@ public function testEntityForm() {
// Switch the layout to two columns.
$this->click('#edit-field-layouts');
- $this->getSession()->getPage()->selectFieldOption('field_layout', 'field_layout_twocol');
+ $this->getSession()->getPage()->selectFieldOption('field_layout', 'layout_twocol');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->submitForm([], 'Save');
@@ -95,7 +95,7 @@ public function testEntityForm() {
$this->drupalGet('entity_test/manage/1/edit');
// No fields are visible, and the regions don't display when empty.
$this->assertFieldInRegion('field_test_text[0][value]', 'left');
- $this->assertSession()->elementExists('css', '.field-layout-region--left .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout-region--left .field--name-field-test-text');
// After a refresh the new regions are still there.
$this->drupalGet('entity_test/structure/entity_test/form-display');
@@ -111,7 +111,7 @@ public function testEntityForm() {
// The new layout is used.
$this->drupalGet('entity_test/manage/1/edit');
- $this->assertSession()->elementExists('css', '.field-layout-region--right .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout-region--right .field--name-field-test-text');
$this->assertFieldInRegion('field_test_text[0][value]', 'right');
// Move the field to the right region without tabledrag.
@@ -142,7 +142,7 @@ public function testEntityView() {
// Switch the layout to two columns.
$this->click('#edit-field-layouts');
- $this->getSession()->getPage()->selectFieldOption('field_layout', 'field_layout_twocol');
+ $this->getSession()->getPage()->selectFieldOption('field_layout', 'layout_twocol');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->submitForm([], 'Save');
@@ -151,8 +151,8 @@ public function testEntityView() {
$this->drupalGet('entity_test/1');
// No fields are visible, and the regions don't display when empty.
- $this->assertSession()->elementNotExists('css', '.field-layout--twocol');
- $this->assertSession()->elementNotExists('css', '.field-layout-region');
+ $this->assertSession()->elementNotExists('css', '.layout--twocol');
+ $this->assertSession()->elementNotExists('css', '.layout-region');
$this->assertSession()->elementNotExists('css', '.field--name-field-test-text');
// After a refresh the new regions are still there.
@@ -171,8 +171,8 @@ public function testEntityView() {
// The new layout is used.
$this->drupalGet('entity_test/1');
- $this->assertSession()->elementExists('css', '.field-layout--twocol');
- $this->assertSession()->elementExists('css', '.field-layout-region--left .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout--twocol');
+ $this->assertSession()->elementExists('css', '.layout-region--left .field--name-field-test-text');
// Move the field to the right region without tabledrag.
$this->drupalGet('entity_test/structure/entity_test/display');
@@ -184,13 +184,13 @@ public function testEntityView() {
// The updated region is used.
$this->drupalGet('entity_test/1');
- $this->assertSession()->elementExists('css', '.field-layout-region--right .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout-region--right .field--name-field-test-text');
// The layout is still in use without Field UI.
$this->container->get('module_installer')->uninstall(['field_ui']);
$this->drupalGet('entity_test/1');
- $this->assertSession()->elementExists('css', '.field-layout--twocol');
- $this->assertSession()->elementExists('css', '.field-layout-region--right .field--name-field-test-text');
+ $this->assertSession()->elementExists('css', '.layout--twocol');
+ $this->assertSession()->elementExists('css', '.layout-region--right .field--name-field-test-text');
}
/**
diff --git a/core/modules/field_layout/tests/src/Kernel/FieldLayoutEntityDisplayTest.php b/core/modules/field_layout/tests/src/Kernel/FieldLayoutEntityDisplayTest.php
index 41bb59d..09f1d79 100644
--- a/core/modules/field_layout/tests/src/Kernel/FieldLayoutEntityDisplayTest.php
+++ b/core/modules/field_layout/tests/src/Kernel/FieldLayoutEntityDisplayTest.php
@@ -40,7 +40,7 @@ public function testPreSave() {
'dependencies' => [],
'third_party_settings' => [
'field_layout' => [
- 'id' => 'field_layout_onecol',
+ 'id' => 'layout_onecol',
'settings' => [],
],
],
@@ -73,7 +73,7 @@ public function testPreSave() {
],
'third_party_settings' => [
'field_layout' => [
- 'id' => 'field_layout_onecol',
+ 'id' => 'layout_onecol',
'settings' => [],
],
'entity_test' => [
diff --git a/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php b/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php
index 40aa155..5d881bc 100644
--- a/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php
+++ b/core/modules/field_layout/tests/src/Unit/FieldLayoutBuilderTest.php
@@ -50,8 +50,8 @@ protected function setUp() {
parent::setUp();
$this->pluginDefinition = new LayoutDefinition([
- 'library' => 'field_layout/drupal.field_layout.twocol',
- 'theme_hook' => 'field_layout__twocol',
+ 'library' => 'field_layout/drupal.layout.twocol',
+ 'theme_hook' => 'layout__twocol',
'regions' => [
'left' => [
'label' => 'Left',
@@ -120,10 +120,10 @@ public function testBuildView() {
],
'#settings' => [],
'#layout' => $this->pluginDefinition,
- '#theme' => 'field_layout__twocol',
+ '#theme' => 'layout__twocol',
'#attached' => [
'library' => [
- 'field_layout/drupal.field_layout.twocol',
+ 'field_layout/drupal.layout.twocol',
],
],
],
@@ -187,10 +187,10 @@ public function testBuildForm() {
],
'#settings' => [],
'#layout' => $this->pluginDefinition,
- '#theme' => 'field_layout__twocol',
+ '#theme' => 'layout__twocol',
'#attached' => [
'library' => [
- 'field_layout/drupal.field_layout.twocol',
+ 'field_layout/drupal.layout.twocol',
],
],
],