Problem/Motivation

Token replacement does not work. Not sure if it only impacts certain combination of modules, occurs when using addressfield, entity_token, and token (locale not installed). The cause appears to be a mismatch in the language code which is set to "en" from $options but the address field is using LANGUAGE_NONE ("und"), as noted in issue #3013566-34: New version doesn't print tokens anymore.

Proposed resolution

Get the language code from the entity instead of options as done in patch for multi-value issue #2679579: Token values unavailable for multi-value address fields

Comments

lwalley created an issue. See original summary.

lwalley’s picture

StatusFileSize
new590 bytes
lwalley’s picture

Status: Active » Needs review
lwalley’s picture

Status: Needs review » Needs work

On second review using language code from entity in the absence of the multi-value patch in #2679579: Token values unavailable for multi-value address fields is probably effectively the same as just setting language code to LANGUAGE_NONE so probably isn't the right choice here. It doesn't solve the root issue which is that $options is "en" but address field array index is "und". Further investigation is needed.

lwalley’s picture

Status: Needs work » Needs review
StatusFileSize
new674 bytes

New patch, also doesn't solve the root cause but at least only changes the language if it isn't supported by address field.

ciss’s picture

StatusFileSize
new897 bytes

I'd like to offer an alternative solution that explicitely checks if the field in question is translatable. I've left patch #5 visible so that both solutions can be compared.

ciss’s picture

Note that these patches still don't handle entity translation. In another project that uses entity translation we ended up patching out addressfield.tokens.inc completely (possible because we already use the entity module and don't rely on underscore field tokens).

tinto’s picture

Patch #5 solves the issue for me