Currently, the render function for content_handler_field_multiple only processes the output through theme_content_view_multiple_field() if there is more than one value to render, and sends the output through unprocessed if there is only one value.
This is a problem, because the outputted rows will have inconsistent markup depending on whether or not there happens to be more than one value in the multiple field for that row. Specifically, theme_content_view_multiple_field wraps each item in a DIV -- otherwise, they're not wrapped in anything.
Check out the attached PNG. "Eligible For" represents a field that takes multiple values. The top row has a single "Eligible For" value, whereas the bottom one has two. Because the programs in the bottom row are individually wrapped, they can be styled. I can't do that in the top row.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | content_handler_field_multiple.inc_.patch | 549 bytes | les lim |
| multiple_field_render.png | 73.53 KB | les lim |
Comments
Comment #1
les limOne possibility is to pass the output through the theme function regardless of how many values are present. Patch attached.
Comment #2
myxelf commentedI'm facing this issue also.
Right now there is no way to theme a single-valued multivalue field at the Views level. The workaround is to create a new formatter (or override an existing one) and do the formatting at that level. But I don't feel this is the way to go.
I don't know why this 6-months-old issue haven't been commented by some of the project members, as the patch in #1 is the solution. *If* the entire issue is correct. Any ideas?
Thanks
Comment #3
myxelf commentedOmit this comment. I got some 'Error 503 Service Unavailable'
Comment #4
sp3boy commentedI have also spent some hours tracking down the cause of this behaviour and am equally surprised that the suggested patch has generated so little comment.
Anyway, the patch applies against 6.x-2.7 and will save me any more time trying other methods to achieve consistent layout of one-value and multiple-value nodes. Thanks to lesmana.
The only outstanding issue I can think of is how this will affect those people who have resorted to custom CCK to get around the absence of a DIV with class field-item around the field if there's only one of them.
Comment #5
Eldon.T commentedpatch works here too against 6x-2.8
i do believe this patch is required to ensure theming consistency.
leave the choice to the themer to count the fields and do additional processing in his hook function "theme_content_view_multiple_field".
Comment #6
alcroito commentedSubscribing