I am relatively new to Craft CMS and I have encountered an issue that I have attempted to debug for quite some time.
When using the {% dd %} function to dump my array, a load of my custom fields display as 'null' apart from the plain text fields.
The custom field that I am looking at returning is 'entryThumbnail'
Below is the dump of array data:
'customFields' => craft\behaviors\CustomFieldBehavior#2
(
[owner] => craft\elements\Entry#1(...)
[yii\base\Behavior:_attachedEvents] => []
[hasMethods] => false
[canSetProperties] => false
[contentBlockOne] => null
[contentBuilder] => null
[entryHeader] => null
[entryThumbnail] => null
[imageSlider] => null
[menus] => null
[navigation] => null
[pageVideo] => null
[seoDescription] => 'TEST'
[seoImage] => null
[seoKeywords] => 'ANOTHER TEST'
[seoTitle] => 'TITLE TEST'
[destinationUrl] => null
[destinationEntry] => null
[label] => null
[menuLabel] => null
[menuEntries] => null
[slideImage] => null
[slideTitle] => null
[slideCaption] => null
[blockBackgroundColour] => null
[blockConfiguration] => null
[textBlock] => null
[imageBlock] => null
[entrySubMenu] => null
[entryDestination] => null
[craft\behaviors\CustomFieldBehavior:_customFieldValues] => []
)
Here is my code that I have written (Looping through a matrix field with the handle 'entrySubMenu') and then attempting to return custom field data of an entry field in the matrix.
{% set menuItems = entry.entrySubMenu.all() %}
{% if menuItems|length %}
{% for menuEntry in menuItems %}
{% set menuEntryItem = menuEntry.entryDestination.one() %}
{% set entryItem = craft.entries().id(menuEntryItem.id).one() %}
{% dd entryItem %}
{% endfor %}
{% endif %}