FilamentF
Filament6mo ago
Nedwor

Select dynamic placeholders

Hello everyone, I'm currently trying to make a select placeholder dynamic.

return Select::make('blabla')
    ->options([$this->options])
    ->live()
    ->disabled(function (Get $get) {
        return $get('is_occupied');
    })
    ->placeholder(function (Get $get) {
        $intervention = $get('intervention'); (something or null)
        return $intervention ?? __('my_placeholder');
    })
    ->afterStateUpdated(function (Set $set, Get $get, $state) {
        $this->handleSomething($set, $get, $state);
    });


In this code I was hoping the placeholder to change if the $intervention is set to null or not. But no, it stays at the first thing it was built with. Good to know, This field is updated when I update a date field in the same form. And the disable works well, just the placeholder stays the same.

Is it possible or am I having a seizure ?
Was this page helpful?