Problem 1: Empty layout option, selecting it causes error message

I have installed a vanilla 8.7.1, no other contrib modules aside Display Suite. When enabling Display Suite and accessing the structure/menu/main/manage display link, on the Layout for main in default tab, the Select layout combo contains the the drupal defined layouts plus the Display Suite ones.

After enabling the Layout Builder from core, clearing the cache and going to the same page, the combo contains one more option after the Display Suite ones under the name of Others, with no text displayed. If one selects that option, an error message appears: An illegal choice has been detected. Please contact the administrator.

Please see the attached photos.

This new option that appears in the list could be an error from the Layout Builder, but if you know that the 'other' option is illegal, maybe it shouldn't appear in the combo.

Problem 2: Display Suite layout is still active after enabling Layout Builder

When enabling Layout Builder for a view mode already using Display Suite for layout, the layout setting for Display Suite still stays active and Layout Builder won't work as expected. One must first select - None - for layout and save the settings before enabling Layout Builder. Not knowing this can cause confusion.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

devarch created an issue. See original summary.

aleksip’s picture

Can confirm the same results with vanilla 8.8.0-dev and Display Suite 3.3.

aleksip’s picture

Issue summary: View changes

Added another problem description as requested by @swentel in #3076819: Display Suite layout is still active after enabling Layout Builder.

swentel’s picture

Status: Active » Needs review
FileSize
647 bytes

This fixes the blank option

swentel’s picture

FileSize
1.67 KB

And this resets ds layouts when you enable layout builder. it also hides the fieldsets which aren't relevant anymore.

  • swentel committed c40f905 on 8.x-3.x
    Issue #3054607 by swentel: Layout builder incompatibility
    

  • swentel committed 8151a5a on 8.x-4.x
    Issue #3054607 by swentel: Layout builder incompatibility
    
swentel’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

donquixote’s picture

This is weird.
The issue was indirectly linked from core issue #3111761: "Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled()" after 8.7.10 to 8.8.0 update, via #3078617: WSOD upon enable with Layout Builder.
So I thought it would fix the problem reported there.

But the error message from the linked core issue #3111761: "Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled()" after 8.7.10 to 8.8.0 update looks like it happened with the code change from this issue already in place:

Error: Call to undefined method
Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled() in
ds_field_ui_fields_layouts()

I just had this happen to me.
Perhaps there are specific scenarios where this happens.

The code snippet in question:

  if (\Drupal::moduleHandler()->moduleExists('layout_builder') && $entity_display->isLayoutBuilderEnabled()) {
    return;
  }

I think the safer thing here would be instanceof, like so:

  if ($entity_display instanceof LayoutBuilderEnabledInterface && $entity_display->isLayoutBuilderEnabled()) {
    return;
  }

Fyi, you can use instanceof with an unknown class:
https://3v4l.org/FgGoP
So this would still work if layout_builder is not enabled.

swentel’s picture

Version: 8.x-3.3 » 8.x-3.x-dev
Priority: Normal » Critical
Status: Closed (fixed) » Active

Hmm, makes sense to check on the interface, reopening.

swentel’s picture

Status: Active » Needs review
FileSize
850 bytes

Should be fine. Code looks more elegant too :)

  • swentel committed c7d8c49 on 8.x-3.x
    Issue #3054607 by swentel, donquixote: Layout builder incompatibility
    

  • swentel committed 3828ee2 on 8.x-4.x
    Issue #3054607 by swentel, donquixote: Layout builder incompatibility
    
swentel’s picture

Status: Needs review » Fixed

committed and pushed, added credit too, thanks!

donquixote’s picture

Cool!
Btw with this "early return" pattern, I like to put the comment inside the if(), like so:

  if ($entity_display instanceof LayoutBuilderEnabledInterface && $entity_display->isLayoutBuilderEnabled()) {
    // The view mode is using layout builder.
    // Don't add any ds-related elements to the form in this case.
    return;
  }

This way the comment can be written in plain sentence describing what "is", instead of using a conditional form describing what "would be".

I also wonder if this check should be moved up a bit.
Some of the variables at the top are not really needed for this check.
Or perhaps move it into ds_form_entity_view_display_edit_form_alter()? Not sure. I think we still want the ds_extras modifications to the form even if it is using layout builder.

Status: Fixed » Closed (fixed)

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

Joe Huggans’s picture

I'm still seeing this issue with the latest version of DS 3.7 and Drupal core 8.8, when trying to save a display on a content type or any entity.

Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled() in ds_field_ui_layouts_save() (line 333 of modules/contrib/ds/includes/field_ui.inc).

I have both DS and Layout builder installed and the previous developer has made it very hard to uninstall any one of them without rebuilding a large part of the website.

Edit: I'm not sure if this will break anything but if I change like 333 of field_ui.inc from

if (\Drupal::moduleHandler()->moduleExists('layout_builder') && $display->isLayoutBuilderEnabled()) {

to

if ($display instanceof LayoutBuilderEnabledInterface && $display->isLayoutBuilderEnabled()) {

This seems to fix the error, but I'm not sure if it is ok or not?

If anyone could let me know I would appreciate it.

swentel’s picture

Status: Closed (fixed) » Needs work

Crap, we totally forgot that part. That will indeed fix the fatal error.

Joe Huggans’s picture

FileSize
728 bytes

Here is a patch.

swentel’s picture

Status: Needs work » Needs review

let's see what the bot thinks

  • swentel committed 9f0df53 on 8.x-3.x authored by joehuggans
    Issue #3054607 by swentel, joehuggans, devarch, aleksip, donquixote:...

  • swentel committed 19081cb on 8.x-4.x authored by joehuggans
    Issue #3054607 by swentel, joehuggans, devarch, aleksip, donquixote:...
swentel’s picture

Status: Needs review » Fixed

Couldn't reproduce the error myself, but the fix makes sense. committed and pushed, thanks!

swentel’s picture

Status: Fixed » Closed (fixed)