Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add descriptionFrom support for nested properties #1128

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/backend/formwidgets/RecordFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaxwilko @bennothommo any thoughts on assigning the modified value back to the local property instead of using a scoped variable at this point? I'm slightly concerned that this current approach causes getDescriptionValue() to have a secondary effect of modifying the value of $this->descriptionFrom in some cases.

}

public function onFindRecord()
Expand Down
Loading