Problem/Motivation

Field Layout should not alter fields placed into regions it doesn't know about.

Proposed resolution

Just don't.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

The last submitted patch, 2: 2920394-field_layout-2-FAIL.patch, failed testing. View results

tedbow’s picture

Status: Needs review » Needs work

Nice test coverage. Proves the problem and the fix!
1 small thing.

+++ b/core/modules/field_layout/src/FieldLayoutBuilder.php
@@ -69,10 +69,12 @@ public function buildView(array &$build, EntityDisplayWithLayoutInterface $displ
         // Move the field from the top-level of $build into a region-specific
         // section.
-        // @todo Ideally the array structure would remain unchanged, see
-        //   https://www.drupal.org/node/2846393.

Before the patch the comments were altogether in 4 lines. Now they are split by the if statement.

If seems like all 4 comment lines should be inside the if statement. With maybe a new comment as to why there would be regions that FieldLayoutBuilder doesn't know about.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
1.22 KB
3.73 KB

Good point! Clarified and reunified the comments.

tedbow’s picture

Status: Needs review » Reviewed & tested by the community

@tim.plunkett thank for the change and the updated comment.

RTBC!

⚾️⚾️⚾️⚾️⚾️⚾️⚾️
⚾️⚾️⚾️🎩⚾️⚾️⚾️
⚾️⚾️👁👁👁⚾️⚾️
⚾️🐬🐬🐬🐬🐬⚾️
⚾️⚾️⚾️⚾️⚾️⚾️⚾️
xjm’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Reviewed & tested by the community » Fixed

Ahoy. This explains things.

I tested it with older versions of the layout builder patch and confirmed that it resolves the "totally empty layout" problem. Does this mean we can remove the hook_requirements() disallowing them from being enabled at the same time?

I fixed a comma splice on commit:

diff --git a/core/modules/field_layout/src/FieldLayoutBuilder.php b/core/modules/field_layout/src/FieldLayoutBuilder.php
index e818992936..fdbefd5e8d 100644
--- a/core/modules/field_layout/src/FieldLayoutBuilder.php
+++ b/core/modules/field_layout/src/FieldLayoutBuilder.php
@@ -69,7 +69,7 @@ public function buildView(array &$build, EntityDisplayWithLayoutInterface $displ
       foreach ($fields as $name => $field) {
         // If the region is controlled by the layout, move the field from the
         // top-level of $build into a region-specific section. Custom regions
-        // could be set by other code at run-time, these should be ignored.
+        // could be set by other code at run-time; these should be ignored.
         // @todo Ideally the array structure would remain unchanged, see
         //   https://www.drupal.org/node/2846393.
         if (isset($regions[$field['region']])) {

I also backported it because it's a mostly non-disruptive bugfix that should only affect code that's not in core yet and shouldn't affect anyone actually using field layout.

xjm’s picture

The comments aren't showing up for it but the commits aren't there. I hope VCS intergration isn't broken again.

  • xjm committed 8b86801 on 8.5.x
    Issue #2920394 by tim.plunkett: Field Layout should not alter fields...

  • xjm committed 585a04f on 8.4.x
    Issue #2920394 by tim.plunkett: Field Layout should not alter fields...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tim.plunkett’s picture

Component: layout.module » field_layout.module