© 2026 Hedgehog Software, LLC

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

Default value and reactive fields

Hi there!
Guys, what's the problem with the default value of the second select 'method'?
I know that if the string
if (!$action) return [];
if (!$action) return [];
is erased, everything works.
So the problem is in the empty array that we return when action is not selected. But even after selecting the 'action' is performed, the default value for 'method' is not stated, it is still null and we see a placeholder here. Action is reactive. What I'm doing wrong? Thanks!

Forms\Components\Select::make('action') 
     ->options(function (Closure $get) {
        return Event::getAvailableActionsForSelect($get('trigger_type'));
    })
     ->reactive(),

Forms\Components\Card::make()
    ->schema(function (Closure $get) {
        $action = $get('action');
        if (!$action) return [];

        return [
            Forms\Components\Select::make('method')
                 ->options([
                     'get' => 'GET',
                     'POST' => 'POST',
                     'PUT' => 'PUT',
                     'PATCH' => 'PATCH',
                     'DELETE' => 'DELETE',
                     ])
                 ->default('get')  
              ]
           }) 
Forms\Components\Select::make('action') 
     ->options(function (Closure $get) {
        return Event::getAvailableActionsForSelect($get('trigger_type'));
    })
     ->reactive(),

Forms\Components\Card::make()
    ->schema(function (Closure $get) {
        $action = $get('action');
        if (!$action) return [];

        return [
            Forms\Components\Select::make('method')
                 ->options([
                     'get' => 'GET',
                     'POST' => 'POST',
                     'PUT' => 'PUT',
                     'PATCH' => 'PATCH',
                     'DELETE' => 'DELETE',
                     ])
                 ->default('get')  
              ]
           }) 
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

Reactive Fields
FilamentFFilament / ❓┊help
15mo ago
Reactive fields
FilamentFFilament / ❓┊help
3y ago
default value on dynamically added form fields
FilamentFFilament / ❓┊help
17mo ago
Setting a default value for hidden fields
FilamentFFilament / ❓┊help
3y ago