I need to format a single field_collection as a table but field_collection_table only seems to work on multiple field_collections. I've tested both 1.0-alpha2 and 1.x-dev.

Please enable 'format as table' functionality for single field_collections!

Comments

naoliva’s picture

Category: feature » bug

I would like to point out that the fact of having a single record for a given field_collection, once possible and accepted by the modules configuration, it is completely regular. There is no reason why field_collection table could not work accordingly in this situation.

That's why in my point of view, this is a minor bug instead of a desirable feature.

jeremymcminn’s picture

Is there a fix for this?

pvdsteen’s picture

Herewith a quick and dirty fix:

Open 'theme.inc' inside the Field Collection Table module.
Find the following function: theme_field_collection_table_multiple_value_fields

In this function #cardinality (line 42 in 7.x-1.0-beta1 version) value needs to be changed from >1 to >0.

Before:
if (isset($element['#cardinality']) && ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED)) {

After:
if (isset($element['#cardinality']) && ($element['#cardinality'] > 0 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED)) {

*edit: For some reason an empty TH and TD are generated when applying this change.
have not been able to figure out why...

PawelR’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new5.69 KB

I think we can remove this check for cardinality.
If I choose table widget and set number of values to 1 I still expect this to be rendered as a table, otherwise I can change the widget.

PawelR’s picture

I'm also sharing this patch, it's re-rolled #4 to apply nicely with #1438266-23 which we also use in our make file.