© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Benjámin

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
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
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),
    ...
];
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Disabling action realtime on state change
FilamentFFilament / ❓┊help
17mo ago
Change State
FilamentFFilament / ❓┊help
15mo ago
Update widget with SelectAction
FilamentFFilament / ❓┊help
12mo ago
Triggering state change
FilamentFFilament / ❓┊help
3y ago