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

bforchhammer’s picture

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

bforchhammer’s picture

bforchhammer’s picture

Part 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.

KarenS’s picture

Status: Active » Closed (duplicate)

I 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.

13rac1’s picture

This 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.

lmeurs’s picture

Issue summary: View changes

I 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.