Smart date always shows a label in Layout Builder even with no value

Created on 10 June 2024, 18 days ago

Problem/Motivation

As part of #3119786: Default values are not displayed for image fields placed in Layout Builder β†’ , Layout Builder attempts to support fields which have a default value set. However the $field->getFieldDefinition()->getDefaultValue($entity) call still returns values for the empty date, so we should probably return an empty array if no value is set.

Steps to reproduce

Using Layout Builder, add a smart date field with no default to a page. The label will be shown even though there is no content to show.

Proposed resolution

Return an empty array for the default value if there is no value set.

Initially opted to patch Layout Builder core, so it checks if that the "main_property" exists in the returned array, but given that's a big assumption on core regarding the field type's default value implementation, it made more sense to address it within the field plugin itself.

Remaining tasks

Provide issue fork/patch.

User interface changes

N/A

API changes

N/A

Data model changes

πŸ“Œ Task
Status

Needs review

Version

4.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024