FilamentF
Filament3y ago
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 []; 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') ] })
Was this page helpful?