Problem/Motivation

Using custom field with a deep (6th level) token in advanced template display causes a fatal error.

Steps to reproduce

Define a Paragraph with a custom_field where a subfield is an entity reference to taxonomy terms.
The taxonomy term include a field that is another custom_field where a subfield X is simply a text field with a select list as widget.
The display of paragraph is using advanced template to show the value of X.
Currently, trying to display the article that includes the paragraph results in a
Uncaught PHP Exception TypeError: "Cannot access offset of type array on array" at web/modules/contrib/custom_field/custom_field.tokens.inc line 302

In my specific case, the template is the following
[paragraph:field_brand_pr_info_base:type:entity:field_tags_info:plural:value]

Proposed resolution

I don't know if it is a problem of a too long token reference, since
[paragraph:field_brand_pr_info_base:type:entity:field_tags_info]
works fine.

Remaining tasks

test

User interface changes

none

API changes

none

Data model changes

?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

giuse69 created an issue. See original summary.

apmsooner’s picture

Status: Active » Postponed

I sort of know whats going on here but its gonna take some time to see if theres a viable solution. Again, I'd recommend familiarizing with twig and custom templates vs. this token display for such advanced requirements in the meantime. When I find some free time however, i'll see if i can get a patch up for you.

giuse69’s picture

Ok, I will wait for a possible solution :)
thanks!

apmsooner’s picture

This patch should resolve the fatal error and would output term properties on the custom field entity reference but any fields on them is still a work in progress. Just wanted to post something here as a placeholder that you may be able to get by with until something more complete is figured out.

giuse69’s picture

hi apmsooner, I was checking daily this thread so this update is welcome.
I can confirm that with the patch I don't get the fatal error any more, but as you say, fields values with deep reference are still not shown.
Thanks

  • apmsooner committed cf4ed6aa on 3.1.x
    Issue #3500781 by apmsooner, giuse69: Fatal error in deep token usage in...
apmsooner’s picture

Status: Postponed » Fixed
Related issues: +#3509249: Deep nested field tokens in entity_reference not replaced

Merging this fix to resolve the fatal error. Creating a new ticket to track the missing field replacements: https://www.drupal.org/project/custom_field/issues/3509249

apmsooner’s picture

Version: 3.1.0 » 3.1.x-dev
apmsooner’s picture

Status: Fixed » Closed (fixed)