How to override `getRecord()` and/or `getLivewireClickHandler()` for an action

No matter what I do in ->getRecord() on my action, I get an error saying Call to a member function form() on null
4 Replies
cheesegrits
cheesegrits15mo ago
What kind of action? Maybe provide some example code of what you have tried.
bwurtz999
bwurtz999OP15mo ago
Action::make('customEdit')
->model(function ($record) {
if($record->type == 'catering') {
$record = Order::find($record->id);
return $record;
}
$record = ExternalOrder::find($record->id);
return $record;
})
Action::make('customEdit')
->model(function ($record) {
if($record->type == 'catering') {
$record = Order::find($record->id);
return $record;
}
$record = ExternalOrder::find($record->id);
return $record;
})
I've also tried
->getModel(function () {
if($record->type == 'catering') {
$record = Order::find($record->id);
return $record::class;
}
$record = ExternalOrder::find($record->id);
return $record::class;
})
->getModel(function () {
if($record->type == 'catering') {
$record = Order::find($record->id);
return $record::class;
}
$record = ExternalOrder::find($record->id);
return $record::class;
})
but I get Typed property Filament\Tables\Actions\Action::$table must not be accessed before initialization I've also tried overwriting ->getLivewireClickHandler() directly but that hasn't worked either The issue I have is that I wrote a custom union to use for a relation manager table. It returns the data correctly but the actions in each row are getting messed up and returning the wrong record when clicked I use standard incrementing IDs in each table So basically, I'm trying to either override the setting of the $record or customize the getLivewireClickHandler so I can add additional parameters to the request
cheesegrits
cheesegrits15mo ago
Ah, OK. Yeah, I can't help with that. If it's two entirely separate tables you are doing a union on in an RM, I can see all kinds of nasty gotchas lurking under the hood which will bite you. Round peg, square hole.
bwurtz999
bwurtz999OP15mo ago
Would using UUIDs instead of regular integers help by any chance? I know I can put these in separate RMs, but I'd like to keep them combined if possible Nevermind - I'm changing how the two different types of orders are created so that they can be used naturally in one RM
Want results from more Discord servers?
Add your server