Closed (duplicate)
Project:
Field collection
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 May 2012 at 14:38 UTC
Updated:
25 Jul 2012 at 01:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
melon commentedHere is the patch, please review.
Comment #2
cwithout commentedThe patch worked to remove the wrapper.
I'm not sure why it's out of the scope of this module for the default field template markup not to be included when the field is empty. I double checked on a fresh install that other field types do not include any markup if their values are empty, and they don't. Shouldn't that be the same for Field Collection?
Comment #3
cwithout commentedLooking at all the other field types, the fact that this one renders markup when the content is completely empty seems like a bug.
I realize Field Collection is slightly different because it includes an "add" link even if the fields are empty, but this definitely causes a problem when you're depending on it to render as empty in order to hide a region for users who don't have permission to add.
The reason it's rendering the the markup even if the field is empty is due to the attached CSS, prefix and suffix, so there needs to be a conditional on including those.
I've only looked at the code briefly, so somebody more familiar with this module might have some better suggestions, but here are a couple ways I can see to do that. The first has more overhead but more stand-alone and not dependent on the return of field_collection_field_formatter_links(). The second less overhead but relies on the -1 index for the element array being created when empty in field_collection_field_formatter_links().
I'm partial to the second for efficiency sake, but not being familiar with the module, I don't know if it's reliable. So I'll leave it to the maintainers to decide or determine if there is a better way.
Comment #4
RobW commentedThis will also be fixed in #1157794: Move markup to template files and improve theming in new 2.x branch. Should have a working patch with all sorts of theme improvements including all markup in tpls, none in the module itself, in a couple of days.
Comment #5
RobW commentedMarking this as a duplicate of #1276258: Completely hide empty field collections. There's been work going on there for a while on this problem. Feel free to bring your patch over there though.