Fix for handling nested fields in the property path.

Created on 1 October 2024, about 2 months ago

Problem/Motivation

The Views Remote Data module provides a way to pull remote data into Drupal views. However, when trying to access deeply nested fields, such as metadata within a remote asset, the current logic fails to retrieve those fields. Specifically, fields like metadata.fields.altText in the remote data structure aren't correctly parsed, leading to empty results or errors.

This is due to the way nested property paths are currently handled in the module. The current implementation attempts to access properties directly, which works only for top-level fields but breaks down for deeply nested arrays or objects.

Steps to reproduce

  1. Configure a view using the Views Remote Data module (acquia_dam_asset_library).
  2. Attempting to access a nested field, such as a property inside an asset’s metadata (e.g., altText), which I obtained from the Map Fields.
  3. Observe that the field returns no data or generates errors when accessed.

Proposed resolution

I have implemented a possible solution that worked in my case, but it needs to be reviewed to determine if it’s the best approach. This solution handles nested fields in the PropertyField plugin by enhancing the getValue() method. It involves checking whether the field is nested, converting it into an array if necessary, and then retrieving the correct value using the NestedArray::getValue() function.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024