Closed ssi-com-pl closed 7 months ago
Hey @ssi-com-pl
Try setting default
to true
in the relation definition so it has an empty model set when the relation is empty.
public $belongsTo = [
'investment' => [
\MyPlugin\Flats\Models\Investments::class,
'key' => 'investments_id',
'default' => true
],
];
Link to docs is here: https://docs.octobercms.com/3.x/extend/database/relations.html#default-models
I hope this helps!
Hi! When I click Link / Unlink in relation field (flats), I get an error: "Call to a member function getKey() on null" on line 7 of \modules\backend\behaviors\relationcontroller\partials_toolbar.php
models/Investments.php
models/investments/fields.yaml
models/Flats.php
models/flats/fields.yaml