Problem/Motivation

The value is always set to TRUE in \Drupal\file\Plugin\Field\FieldWidget\FileWidget::process (line 411) and causes invalid values from FormState::getValues after calling FormBuilder::buildForm if the form isn't submitted

Steps to reproduce

Create an entity form with an image widget
Call buildForm on the form builder for that form and inspect $form_state->getValue(['your_field_name', 0, 'display']) and note it will be FALSE despite the value being hard-coded to 1 in \Drupal\file\Plugin\Field\FieldWidget\FileWidget::process

Proposed resolution

Override ::defaultStorageSettings for ImageItem and set display_default to TRUE (hence overriding FileItem::defaultStorageSettings()' default of FALSE).

Remaining tasks

None.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Issue fork drupal-3513317

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

larowlan created an issue. See original summary.

annmarysruthy made their first commit to this issue’s fork.

annmarysruthy’s picture

Status: Active » Needs review
larowlan’s picture

Thanks, added a test

wim leers’s picture

Title: ImageItem::defaultStorageSettings should override display_default » ImageItem::defaultStorageSettings() should override display_default
Issue tags: +Experience Builder, +Contributed project blocker
wim leers’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Related issues: +#3512017: Changing a value in Page form then publishing, Auto-save shows a change when there is not one

Test looks solid.

I'd run the test-only CI job, but I don't have permission to do so 😇

wim leers’s picture

  • longwave committed 414748a5 on 10.4.x
    Issue #3513317 by annmarysruthy, larowlan, wim leers: ImageItem::...

  • longwave committed 6bb7ed74 on 10.5.x
    Issue #3513317 by annmarysruthy, larowlan, wim leers: ImageItem::...

  • longwave committed 7365716b on 11.1.x
    Issue #3513317 by annmarysruthy, larowlan, wim leers: ImageItem::...

  • longwave committed 72658312 on 11.x
    Issue #3513317 by annmarysruthy, larowlan, wim leers: ImageItem::...
longwave’s picture

Version: 11.x-dev » 10.4.x-dev
Status: Reviewed & tested by the community » Fixed

Backported down to 10.4.x as an eligible bug fix and contrib blocker.

Committed and pushed 72658312419 to 11.x and 7365716bb37 to 11.1.x and 6bb7ed74434 to 10.5.x and 414748a59c7 to 10.4.x. Thanks!

Status: Fixed » Closed (fixed)

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