Line 1664 of entityform.module reads as follows:
$text = token_replace($text, $token_types);
I think it needs to be:
$text = token_replace($text, $token_types, array('clear' => TRUE));
From https://api.drupal.org/api/drupal/includes%21token.inc/function/token_re...
"clear: A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated."
Explanation:
I have an entityform with a token "Work phone: [current-user:profile-addresses-email:field-work-phone]" in the "Intro form instructions" field. (I'm trying to show the user what information we have on file in case changes are necessary.)
If "field-work-phone" has a value, the token is replaced correctly. If it's empty, it's returning the token string itself. so the user sees something like:
Work phone: [current-user:profile-addresses-email:field-work-phone]
That's not right, is it? Methinks it's better to show nothing instead of the unreplaced token.
This is a filtered text field using CKeditor if that matters, but I tried it as other formats with the same outcome.
Patch coming momentarily for your consideration.
Comment | File | Size | Author |
---|---|---|---|
#1 | entityform-token-fix-2349247-2.patch | 486 bytes | rclemings |
Comments
Comment #1
rclemings CreditAttribution: rclemings commentedComment #2
tedbowYour change seems good. I just why token_replace is so often called without 'clear' option.
Doing a quick search of core toke_repalce is called 71 times and I only see "'clear' => TRUE" 3 times.
Anybody of any idea of side effects?
Comment #4
tedbow@rclemings thanks for the patch! commited
Comment #5
tedbow