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
?
Issue fork custom_field-3500781
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
Comment #2
apmsooner commentedI 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.
Comment #3
giuse69 commentedOk, I will wait for a possible solution :)
thanks!
Comment #5
apmsooner commentedThis 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.
Comment #6
giuse69 commentedhi 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
Comment #8
apmsooner commentedMerging 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
Comment #9
apmsooner commentedComment #10
apmsooner commented