When using a name token exposed via an entity reference field, tokens do not work.

Comments

aaronbauman created an issue. See original summary.

aaronbauman’s picture

Status: Active » Needs review
StatusFileSize
new727 bytes

Here's a simple patch that fixes this for my case.

In a nutshell: name_tokens() makes the incorrect assumption that $type is equivalent to $entity_type.
$type is actually the token type, which can sometimes be an entity type (e.g. "user" or "node"), but sometimes is a token type (e.g. "commerce-order"). $type needs to be transformed to $entity_type (hyphens replaced with underscores) before sending to field_get_items().

This patch will not have any adverse side effects, since it merely fixes tokens that are broken.
(ie. there are no entity types with hyphens in their machine name - only underscores are allowed).
It will not break any tokens that are working now.

For a thorough background on a very similar issue, please see #2225215: Improper 'token type' definitions in hook_entity_info() implementations

rooby’s picture

Status: Needs review » Reviewed & tested by the community

This also makes name tokens work when I have a name field in a customer profile on a commerce order.

  • Alan D. committed 54bbaf5 on 7.x-1.x authored by aaronbauman
    Issue #2561897 by aaronbauman: Name tokens still do not work for entity...
alan d.’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.