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.
I have a date-field which has a "to date" and allows multiple values. I get the following token values:
[node:field-multiple-dates]
= "Property 0"[node:field-multiple-dates:value]
=>Fatal error: Call to a member function value() on a non-object in \sites\all\modules\entity\entity_token.tokens.inc on line 297
I have verified this on a clean drupal install with latest version of drupal, and latest dev versions of date and entity.
Steps to reproduce:
- Create a new "Date" field
field_multiple_dates
- On field settings:
- change "Number of values" to "Unlimited"
- Tick "Collect an end date"
- Create a node, enter at least one date (one is enough for things to "break")
- Test the
[node:field-multiple-dates]
token
This is a new issue as per #1530042-16: Get Entity Tokens working; see that issue for more comments / error reports.
Comments
Comment #1
bforchhammer CreditAttribution: bforchhammer commentedI traced back the fatal error back to line 183 in
entity_token.tokens.inc
:$replacement = _entity_token_get_token($wrapper->$property_name, $options);
When I use tokens for the format "[node:field-date:value]", then
$wrapper
is an instance of EntityListWrapper, and$property_name
is "value" (or whatever is used after the colon in the token); this results in NULL being passed to_entity_token_get_token()
, which then causes the fatal error...I'd be happy to roll a patch, but I have absolutely no idea how to fix this... Any advice?
Comment #2
bforchhammer CreditAttribution: bforchhammer commentedPossibly related: #1520420: Entity tokens for multi-value fields still not working (or need documention).
Comment #3
bforchhammer CreditAttribution: bforchhammer commentedPart of the problem seems to lie with using
list<struct>
as the type for date field properties; this probably needs to be solved in the entity module, see #1621084: Support list<struct> type tokens.Comment #4
KarenS CreditAttribution: KarenS commentedI don't think any part of this issue is anything that can be controlled by the Date module. There are a couple links to Entity API issues, which is what this probably is.
Comment #5
13rac1 CreditAttribution: 13rac1 commentedThis is currently a dupe of #1440928: Entity tokens for multi-value fields produce a fatal error. Although, with the linked patch applied, there are no errors, but nothing appears for the value, value2 tokens.
Comment #6
lmeurs CreditAttribution: lmeurs commentedI second #5: applied the patch from #1440928: Entity tokens for multi-value fields produce a fatal error, the error disappears, but unfortunately tokens do not work.