From 841ee8c8a11631f89c17f2f021e4126b231a08f8 Mon Sep 17 00:00:00 2001 From: AIC BV <89913092+AIC-BV@users.noreply.github.com> Date: Thu, 16 May 2024 09:33:16 +0200 Subject: [PATCH] Add descriptionFrom support for nested properties Adds support for JSON columns descriptionFrom: name descriptionFrom: json.name descriptionFrom: json[name] --- modules/backend/formwidgets/RecordFinder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index 982e12dc01..81051f136a 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -290,7 +290,12 @@ public function getDescriptionValue() return null; } - return $this->relationModel->{$this->descriptionFrom}; + // Convert array-like notation to dot notation + if (preg_match('/\[(.*?)\]/', $this->relationModel, $matches)) { + $this->descriptionFrom = str_replace(['[', ']'], ['.', ''], $this->descriptionFrom); + } + + return data_get($this->relationModel, $this->descriptionFrom); } public function onFindRecord()