Field default value does not show in the block

Created on 11 November 2015, about 9 years ago
Updated 26 July 2023, over 1 year ago

Problem

copy-paste from #14:
Unfortunately, Drupal core is inconsistent in it's implementation of default field values. I compared an image field with a default value to a text field with a default value and this is what I found:

This means we have two problems when handling default values in our blocks:

  1. For fields such as the text field, we cannot tell the difference between a default value and a user-entered value. We can check if the field is empty but we cannot offer an option to hide the block when the field contains the default value.
  2. For fields such as the image field (probably file fields too), the field API (getDefaultValue()) does not allow us to retrieve the default value when the field is empty. (Maybe it would be possible if FileFieldItemList would implement FieldItemListInterface::processDefaultValue, but that would be a core issue.) In theory we could add workarounds specifically for image/file fields, but I'm not keen on that.

Solution

To be decided.

Original bug report

If image field has default image set the default image does not get displayed in the field block.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇫🇮Finland terotik

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024