Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
_entity_token_get_token does not handle text_formatted fields.
The following try doesn't work:
--- a/docroot/sites/all/modules/contrib/entity/entity_token.tokens.inc
+++ b/docroot/sites/all/modules/contrib/entity/entity_token.tokens.inc
@@ -325,6 +325,8 @@ function _entity_token_get_token($wrapper, $options) {
case 'uri':
case 'text':
return $wrapper->value($options);
+ case 'text_formatted':
+ return $wrapper->value()['value'];
}
How can I support struct values?
Comment | File | Size | Author |
---|---|---|---|
#4 | entity-2185745-4.patch | 419 bytes | geoffreyr |
Comments
Comment #1
lokapujyaPartially fixed by #1621084: Support list<struct> type tokens. But the patch needs more work. I used two formatted text tokens in a rules email. One of the two is fixed. The other is now blank.
Comment #2
lokapujyaI have two filtered text fields. One of them is being treated as type text, and the other is being treated as a struct. The one that is treated as a struct is working. Not sure why the other one is treated as text.
Comment #3
lokapujyaThe issue is that I used the same field in two different content types. In one content type it is text, in another it is text_formatted. So, once the field gets loaded as text, it must get cached and then the second content type doesn't get loaded as text_formatted. I worked around the bug, by making both fields text_formatted.
Comment #4
geoffreyr CreditAttribution: geoffreyr commentedTurned this one into a patchfile because I found it useful.
Comment #5
lokapujyaThis module has automated tests. I wonder what happens with this patch. Will try to kick it off.
Comment #6
lokapujyaNot sure if this is even overall the right solution. But if the code is used, I guess that since we have to support PHP 5.3, it should use a tmp variable: