Call to a member function isRelation() on null

I have the following createOptionAction where that I am getting that isRelation() on null error
->createOptionAction(function ($action, Get $get) {
// hide the button to create a unit if this is a property that can't have multiple units
$property = Property::find($get('property_id'));
if ($property) {
if (! $property->canHaveMultipleUnits()) {
return $action->hidden();
}

return $action
//->record(fn ($livewire) => $livewire->model)
->fillForm([
'property_id' => $property->id,
])
->slideOver()
->modalWidth('7xl')
->modalHeading('Create Unit');
}

return $action->hidden();
})
->createOptionAction(function ($action, Get $get) {
// hide the button to create a unit if this is a property that can't have multiple units
$property = Property::find($get('property_id'));
if ($property) {
if (! $property->canHaveMultipleUnits()) {
return $action->hidden();
}

return $action
//->record(fn ($livewire) => $livewire->model)
->fillForm([
'property_id' => $property->id,
])
->slideOver()
->modalWidth('7xl')
->modalHeading('Create Unit');
}

return $action->hidden();
})
. ->record() isnt available on this form action though, so i cant use it, which appears to be the solution for the issue. The problem is that in this form, I am trying to use a select with a relationship(), which throws that error. Recommendations?
1 Reply
jamesro
jamesro7d ago
this is how I solved on such error
->createOptionForm(function (Form $form) {
return DepartamentResource::form($form);
})
->createOptionForm(function (Form $form) {
return DepartamentResource::form($form);
})

Did you find this page helpful?