© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Arif Hossain

How can i add select option dynamically from suffixAction ?

I have a select field with one option initially. I have also added a suffixAction to pick a record and trying to add new option from picked record dynamically to select field. but can't do it. can anyone help please?
Forms\Components\Select::make('union_id')
->label(__('labels.union'))
->options(function (): array {
$union = Union::find(auth()->user()->location[0]);
return [
    $union->id => $union->name_bn
];
})
->suffixAction(
Forms\Components\Actions\Action::make("select_union")
    ->icon('heroicon-o-plus')
    ->modalHeading(__('labels.select_union'))
    ->form(self::locationForm())
    ->modalCancelAction(false)
    ->modalSubmitActionLabel(__('labels.select'))
    ->action(function (Set $set, $state, array $data, Component $component) {

    $union = Union::find($data['union']);
    $component->options([
        $union->id => $union->name_bn
    ]);
    $set('union_id', $union->id);
    
    }),
)
Forms\Components\Select::make('union_id')
->label(__('labels.union'))
->options(function (): array {
$union = Union::find(auth()->user()->location[0]);
return [
    $union->id => $union->name_bn
];
})
->suffixAction(
Forms\Components\Actions\Action::make("select_union")
    ->icon('heroicon-o-plus')
    ->modalHeading(__('labels.select_union'))
    ->form(self::locationForm())
    ->modalCancelAction(false)
    ->modalSubmitActionLabel(__('labels.select'))
    ->action(function (Set $set, $state, array $data, Component $component) {

    $union = Union::find($data['union']);
    $component->options([
        $union->id => $union->name_bn
    ]);
    $set('union_id', $union->id);
    
    }),
)
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to update option label using suffixaction?
FilamentFFilament / ❓┊help
7d ago
Dynamically update rules based on Select option
FilamentFFilament / ❓┊help
2y ago
refresh select after suffixAction completed
FilamentFFilament / ❓┊help
2y ago
How to filter select option from another select value
FilamentFFilament / ❓┊help
3y ago