Skip to content

Commit

Permalink
add relation property
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Oct 17, 2023
1 parent 1d3d963 commit 49c22f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/backend/formwidgets/RelationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ class RelationManager extends FormWidgetBase
*/
protected $recordOnClick;

/**
* @var string relation name if different from the field name.
*/
protected $relation;

public function init(): void
{
$this->fillFromConfig([
'readOnly',
'recordUrl',
'recordOnClick',
'relation',
]);

if (!isset($this->readOnly)) {
Expand All @@ -60,7 +66,9 @@ public function render()
$options['recordOnClick'] = $this->recordOnClick;
}

return $this->controller->relationRender($this->formField->fieldName, $options);
$relation = $this->relation ?: $this->formField->fieldName;

return $this->controller->relationRender($relation, $options);
}

public function getSaveValue($value)
Expand Down

0 comments on commit 49c22f1

Please sign in to comment.