Needs work
Project:
Drupal core
Version:
main
Component:
file system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2020 at 09:39 UTC
Updated:
3 Jul 2025 at 17:04 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
odai atiehComment #3
odai atiehComment #5
swatichouhan012 commentedComment #7
odai atieh@swatichouhan012
No need for "link_to_file" checkbox to be displayed, so I added
unset($form['link_to_file']);.File link formatter should be link so
$settings['link_to_file'] = TRUE;shouldn't be changed.Comment #8
hardik_patel_12 commented@Odai Atieh Link this field checkbox is not appearing , tried to handle that and removing duplication of settings. Kindly review the patch
Comment #9
hardik_patel_12 commentedComment #10
odai atiehComment #12
odai atiehComment #14
hardik_patel_12 commentedKindly review a new patch.
Comment #15
quietone commentedI tested this on 9.2.x and can confirm the patch works.
As always this will need a test.
Comment #16
mohit_aghera commentedSpotted one issue while writing test cases that value is not getting saved when we change the value.
Fixed issue in current patch.
Added test cases to ensure that no additional fields are present.
Added test case for other field formatter related configurations to ensure that checkbox field works as expected..
Comment #17
mohit_aghera commentedAdding test-only patch for reference.
Comment #18
mitthukumawat commentedThe patch #16 applied successfully and the field formatter is not longer showing twice in files view configurations.
Adding screenshots for reference.
RTBC+1
Comment #20
mohit_aghera commentedChanging to needs review as failures is due to test-only patch.
Comment #23
vikashsoni commentedpatch #14 working fine and applied successfully
After patch field formatter is not showing with twice
Thanks for the patch
For ref sharing screenshot ...
Comment #24
hmendes commentedThe patch from #16 worked for me on Drupal 9.4.x
Steps:
The Test-only patch shows the problem and the patch fix it, so changing this to RTBC.
I'll not provide prints as it is basically the same from #18 and #23.
Comment #25
alexpottI'm not sure this fix is correct. The \Drupal\file\Plugin\Field\FieldFormatter\DefaultFileFormatter widget is used in more contexts than just views. For example, entity displays. This formatter is supposed to always link to a file. As far as I can see it is not meant to be optional. The description of the formatter is:
Comment #30
mohit_aghera commentedI've debug the issue further.
Duplicate form is appearing because we are returning
$formin the field formatter.When call comes to field formatter, it already has all the options in the form. See https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/views...
Once we return
$formas it is, it gets merged into existing form array.Line 540-542 https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/views...
This is causing the duplicate form fields.
I believe returning empty array should fix the problem.
Comment #31
smustgrave commentedLeft some comments after reading #30 but am tagging for summary update as proposed solution doesn't seem to line up.