Issue

Most Fences templates render out field items with a foreach loop and call render() over each item. The render call is wrapped in some HTML for the respective element, For example, field--fences-strong.tpl.php.
The issue arises when the item may not be visible in its current scope, I.E. $item['#access'] = FALSE;. The render function obeys this and does not render the item, however fences still wraps the item which leads to dirty markup.

Proposed Solution

When fences will contribute a template suggestion to a rendering field (in hook_preprocess_field), it should also sanitize the items variable to ensure only visible items are passed to the template.
See patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Josh Waihi’s picture

I found the previous patch mismatched existing elements and still broke fences integration. This patch now address and fixes the issue correctly.

Josh Waihi’s picture

Wrong format. Here is the patch with the correct formatting.

JohnAlbin’s picture

Issue summary: View changes
Status: Needs review » Postponed (maintainer needs more info)

Hmmm…

This is a core bug, no? Core's default theme_field() has the same behavior. https://api.drupal.org/api/drupal/modules%21field%21field.module/functio...

I'm hesitant to work-around this in Fences without a corresponding issue in core.

Anybody’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)