The label for the file field still shows even when there are no attached files when using the table formatter.

I was able to fix it by adding

if(count($items) > 0)

on line 964 of file.field.inc

Comments

lyricnz’s picture

Version: 7.x-dev » 8.x-dev
Assigned: Unassigned » lyricnz
Issue tags: +Needs backport to D7
StatusFileSize
new1.59 KB

Can confirm issue. Have fix here, but writing tests. Will provide tonights.

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new2.75 KB
new1.16 KB

Here's a patch to file.test that adds a test for labels being suppressed when file fields are empty. With the current codebase it gets: 36 passes, 1 fail, 0 exceptions, and 14 debug messages.

The second attachment the test, plus fix from #1, for a CNR patch.

mjpa’s picture

Status: Needs review » Reviewed & tested by the community

Works fine for me on D7. Surprised to see such an old issue for such a trivial thing to fix...

dries’s picture

A before and after screenshot would be really helpful.

lyricnz’s picture

- stock D8 install (disabled/reenabled JS during install to work around current install bug)
- added new field "stuff" as unlimited multi-value file field to "article"
- change format of field to "table of files"
- created an article with no files attached
- screenshots supplied: config, before, after

(D7 patch was applied to D8 from /core directory with some offsets)

lyricnz’s picture

Rerolled patch for D8, no other change.

xjm’s picture

Screenshots explain it quite well. This also has a test, so +1 on the RTBC.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. I also re-rolled the patch to 7.x and committed it to 7.x. Thanks for providing those screenshots; that was helpful.

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