Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When the default field behavior is set to not display files, the default is not respected on the content creation page.
- Install Drupal with minimal profile.
- Enable Field UI and File modules.
- Create a content type.
- Add a file field to the content type.
- Check "Enable Display field" and leave "Files displayed by default" unchecked.
- Go to the content creation page and upload a file.
Expected result: "Include file in display" is unchecked.
Actual result: it is checked.
Proposed resolution
Fix the bug. Make the field follow the default as set in the content type.
Remaining tasks
Needs Review. Possibly a manual test with a screenshot.
User interface changes
none.
API changes
none.
Beta phase evaluation
Issue category | Bug |
---|---|
Unfrozen changes | Unfrozen because it only changes code to fix a bug that also exists in Drupal 7 |
Prioritized changes | The main goal of this issue is usability. |
Comment | File | Size | Author |
---|---|---|---|
#45 | files_displayed_by-1520716-45.patch | 2.22 KB | djdevin |
#41 | 1520716-41.patch | 2.1 KB | lokapujya |
#41 | 1520716-41-test-only.patch | 1.51 KB | lokapujya |
#33 | 1520716-33-test-only.patch | 1.62 KB | lokapujya |
#31 | interdiff-1520716-31.txt | 948 bytes | lokapujya |
Comments
Comment #1
David Lesieur CreditAttribution: David Lesieur commentedComment #2
bskibinskiTested the patch from #1 and it seems te work perfectly!
Comment #3
carsonwThe patch from #1 is simple and sweet, and it works perfectly. Can we get this committed to core?
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedThis looks very reasonable, but needs to go into Drupal 8 first.
It also seems like there should be tests?
Comment #5
swentel CreditAttribution: swentel commentedComment #6
pawel.traczynski CreditAttribution: pawel.traczynski commentedI tested patch from #1 and it works for me.
Can you move this to D7 core please? :) Let add it into D7 instead of having system where some things are broken ^^
Comment #7
chrisfromredfinLet's see if this change breaks anything in the current D8 test suite. Then we'll write a test for this case (I'm not super up on how to write tests so don't want to wait to get this small piece moving along regardless.)
Comment #9
lokapujyaModified the File Field Display Test.
Still need to get the FileFieldRSSContentTest to work.
Comment #10
lokapujyaComment #12
lokapujyaRerolled. Plus, progress on a fix for FileFieldRSSContentTest.
Comment #14
lokapujyaMaybe the original tests were ok.
Comment #15
lokapujya14: 1520715-14.patch queued for re-testing.
Comment #16
carsonwI can't believe the patch in #1 hasn't been committed to D7 core yet. I have to apply it every time I upgrade Drupal. Can we please get it committed?
Comment #19
lokapujyaComment #20
lokapujyaComment #22
lokapujyaComment #23
jhedstromCan somebody update the issue summary? The patch in #20 still applies.
Comment #24
lokapujyaComment #25
lokapujyaComment #26
lokapujyaComment #27
jhedstromThere's a spacing issue between the 'if' and the opening parenthesis here.
Also, since
isset($item['display'])
is already being called, the line below can probably be simplified to'#value' => $item['display']
.Comment #28
lokapujya$item['display'] is a boolean, the display value is '1' if checked.
Comment #29
jhedstromThis fixes a bug that also exists in Drupal 7.
I've updated the issue summary to include a beta phase evaluation.
Comment #30
alexpottIt looks like we also need an assertion that the expected display is there if the setting is changed. Just having an
assertNoFiledByXPath
is prone to creating false positives.Comment #31
lokapujyaVery good point. Do you like this better?
Comment #32
jhedstromSince the test changed, could you re-attach that as a separate patch to show current failures?
Comment #33
lokapujyaTest only to show the fail.
Comment #35
jhedstromI think the patch in #31 addresses the concerns in #30. The patch in #33 is the test only and was expected to fail. Back to RTBC I think.
Comment #36
alexpottYep I do prefer #31 - nice work @lokapujya. Committed d6be512 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Comment #38
lokapujyaComment #39
lokapujyaand the D7 versions.
Comment #40
lokapujyaforgot something.
Comment #41
lokapujyaChanged the tests as we did in the D8 patch.
Comment #44
lokapujyaComment #45
djdevinRe-rolled and RTBC.
Edit: to review but...really should be RTBC after this.
Comment #46
djdevinComment #47
lokapujyaTested. I removed the fix and verified that the test fails without the fix, too.
Comment #48
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted to 7.x - thanks!
Comment #51
sksshed CreditAttribution: sksshed commentedI know this was a couple of years ago but I am having the same issue, was the patch realised into Drupal 7 core?
Comment #52
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedYes, this was committed in October 2015 and included in Drupal 7.40 and above.
I tested now and it still works for me in the latest Drupal 7 release. If it isn't working for you, please create a new issue with details on how to reproduce the problem (and link to it from here). Thanks!