Problem/Motivation

When show_empty is enabled, and the field is both empty and is being render in Layout Builder, the field never displays. I haven't been able to determine if this is an issue with Layout Builder, or can be resolved in the Office Hours code base.

Steps to reproduce

  1. Create an entity with an Office Hours field.
  2. Set up the entity's display settings is set to use Layout Builder
  3. Add the hours field to the layout.
  4. Set show_empty to TRUE.

Proposed resolution

Ideally, the field would still render just with every day marked as closed, like when the field isn't in Layout Builder.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

jeremyvii created an issue. See original summary.

kalpanajaiswal’s picture

I tried to replicate the issue but it didn't reproduce.
Drupal version: 10.2.7
office_hours module version: 1.17.0

jeremyvii’s picture

In order to replicate, all the hours must empty on the entity.

Without Layout Builder.
Without Layout Builder

With Layout Builder
With Layout Builder

johnv’s picture

Status: Active » Postponed (maintainer needs more info)

This should not be possible. I guess all other settings are not used then, too. Please check that.
Please check if the correct ViewMode is used.
IN the code, you can see several references to layout_builder please grep them and test the behaviour.

jeremyvii’s picture

I can confirm that I am using the correct view mode. After further investigation, this appears to be happening with any field in Layout Builder. In Drupal\layout_builder\Plugin\Block\FieldBlock::blockAccess, the selected field's isEmpty() method is checked, and if true, access to the block is forbidden. There appears to be an issue for the Drupal project to try to add a setting to allow the field to display, even if empty. It would be nice OfficeHoursItemList::isEmpty() returned false if show_empty is checked, but I can understand how that would be messy to implement.

  1. Drupal\layout_builder\Plugin\Block\FieldBlock::blockAccess
  2. #3067982: Formatters for empty fields do not render with layout builder enabled
johnv’s picture

I tried to move the 'show_empty' into $items->isEmpty(), but the formatter settings are lost in the ItemList.
I does not seem right to override the layout_builder code, even if it core.
Also, it seems as I have a higher Drupal version then you, since in my 10.2.x system, #3119786: Default values are not displayed for image fields placed in Layout Builder is committed, removing the line you mention.
Perhaps the problem is solved in a higher Drupal version?