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.

CommentFileSizeAuthor
#1 entityform-token-fix-2349247-2.patch486 bytesrclemings
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rclemings’s picture

Status: Active » Needs review
FileSize
486 bytes
tedbow’s picture

Your 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?

  • tedbow committed d40cfc8 on 7.x-2.x authored by rclemings
    Issue #2349247 by rclemings: Fixed Empty tokens not replaced in filtered...
tedbow’s picture

@rclemings thanks for the patch! commited

tedbow’s picture

Status: Needs review » Fixed

  • tedbow committed d40cfc8 on 7.x-2-metatags-2344293 authored by rclemings
    Issue #2349247 by rclemings: Fixed Empty tokens not replaced in filtered...

Status: Fixed » Closed (fixed)

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