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
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
Comment #4
annmarysruthy commentedComment #5
larowlanThanks, added a test
Comment #6
wim leersComment #7
wim leersTest looks solid.
I'd run the test-only CI job, but I don't have permission to do so 😇
Comment #8
wim leersComment #13
longwaveBackported 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!