Replies: 1 comment
-
Hi @LiquidPL , public function prepareFieldsBeforeSave($object, $fields)
{
$fields['belongsToModel_id'] = array_get($fields, 'browsers.browserName.0.id', null);
return parent::prepareFieldsBeforeSave($object, $fields);
}
public function getFormFields($object)
{
$fields = parent::getFormFields($object);
$belongsToModel = $object->belongsToModel;
if ($belongsToModel) {
$fields['browsers']['browserName'] = collect([
[
'id' => $belongsToModel->id,
'name' => $belongsToModel->title,
'edit' => moduleRoute('belongsToModuleName', 'routePrefix', 'edit', $belongsToModel->id),
'thumbnail' => $belongsToModel->defaultCmsImage(['w' => 100, 'h' => 100]),
],
])->toArray();
}
return $fields;
} and of course, a PR for adding support for this feature will be very welcomed! Please let us know if you need any help. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to use a browser field to set a one-to-many relationship between two of my models, however I've noticed that it's only supporting many-to-many fields currently.
Are there any plans to add one-to-many support? If not, would you be willing to accept PRs on that? I would be interested in making one.
Beta Was this translation helpful? Give feedback.
All reactions