We have a content type with a term reference field that is hidden on page display, and while working with the Metatags module I noticed that tokens referencing fields that are hidden on the page display type were not being populated, and in fact were generating errors in the taxonomy field module. If I made the field visible in the display type, it worked fine.
Further investigation through the call stack found that the entity being used was already processed for the current page display type (in which the hidden fields were not fully processed), and when subsequent field format calls were made on the entity's fields, no hook_field_formatter_prepare_view hooks were being invoked on the fields due to $entity->_field_view_prepared being set to TRUE on the cloned entity.
This patch resets that flag on the cloned entity prior to running through the field rendering code, allowing all fields to be rendered on the entity for the "token" display type, resulting in all field tokens being processed fully and available for use.
Comment | File | Size | Author |
---|---|---|---|
#7 | token-field-view-prepare-reset-1508404-7.patch | 641 bytes | jec006 |
#4 | token-7.x-1.0-rc1-field_view_prepared_reset-1508404.patch | 645 bytes | arpieb |
#2 | token-7.x-1.0-rc1-field_view_prepared_reset.patch | 658 bytes | arpieb |
token-7.x-1.0-rc1-field_view_prepared_reset.patch | 576 bytes | arpieb | |
Comments
Comment #2
arpieb CreditAttribution: arpieb commentedBotched patch generation - here's a good one.
Comment #4
arpieb CreditAttribution: arpieb commentedThird time's the charm...
Comment #5
arpieb CreditAttribution: arpieb commentedComment #7
jec006 CreditAttribution: jec006 commentedHere's a better version
Comment #8
Dave ReidMakes sense since this seems to happen because meta tag calls token replacement from within hook_field_attach_view(). Committed to 7.x-1.x with http://drupalcode.org/project/token.git/commit/34b6142