SelectAction state change action

What does SelectAction call when the selection change? I'm trying to solve model versioning with it, so after the selection i'd redirect the user to the given version, how can I implement this?
SelectAction::make('versions')
->options(function (Offer $record) {
return $record->previousVersions();
})
->afterStateUpdated(function ($state) {
// Tried this method, but it doesn't exist.
}),
SelectAction::make('versions')
->options(function (Offer $record) {
return $record->previousVersions();
})
->afterStateUpdated(function ($state) {
// Tried this method, but it doesn't exist.
}),
Solution:
I ended up to a solution like this with ActionGroup: looping through the versions, and push actions to an array: ``` foreach ($recordVersions as $version) {...
Jump to solution
6 Replies
Benjámin
BenjáminOP14mo ago
up, please?
LeandroFerreira
LeandroFerreira14mo ago
Where is it?
Benjámin
BenjáminOP14mo ago
Edit page header
Solution
Benjámin
Benjámin14mo ago
I ended up to a solution like this with ActionGroup: looping through the versions, and push actions to an array:
foreach ($recordVersions as $version) {
$versions[] = Action::make('version' . $version->id)
->label($version->serial)
->disabled(fn (Offer $record): bool => $record->id === $version->id)
->url(route('filament.admin.resources.offers.edit', ['record' => $version->id]));
}
foreach ($recordVersions as $version) {
$versions[] = Action::make('version' . $version->id)
->label($version->serial)
->disabled(fn (Offer $record): bool => $record->id === $version->id)
->url(route('filament.admin.resources.offers.edit', ['record' => $version->id]));
}
And then made an ActionGroup with that variable:
return [
ActionGroup::make($versions)
->button()
->color('gray')
->label('Versions')
->icon('heroicon-m-chevron-down')
->iconPosition(IconPosition::After)
->hidden(count($recordVersions) <= 1),
...
];
return [
ActionGroup::make($versions)
->button()
->color('gray')
->label('Versions')
->icon('heroicon-m-chevron-down')
->iconPosition(IconPosition::After)
->hidden(count($recordVersions) <= 1),
...
];
LeandroFerreira
LeandroFerreira14mo ago
GitHub
Wire:change Event in SelectAction · filamentphp filament · Discussi...
Hello everyone, Is there a way to trigger the wire:change event when selecting an item from a SelectAction? Or do I need to create a custom component?" protected function getHeaderActions(): a...
vanhellsing101
vanhellsing1017mo ago
The solution helped me a lot thanks! I was looking in the wrong direction trying to use SelectAction.
Want results from more Discord servers?
Add your server