Bart_
Bart_
FFilament
Created by Bart_ on 12/21/2023 in #❓┊help
Unexpected behaviour of Select searchable()
Hey! I am not sure if this is a bug or some weird feature but as far as I can see it is nowhere documented and in my opinion unexpected behaviour. I have 2 Select inputs where one will be visible when the other one is filled. The first one is searchable(). This causes the value not being passed to the FIlament side so the other Select will never show. This is code to try it out:
Select::make('option1')
->options([
'ipsum' => 'ipsum',
'lorem' => 'lorem',
])
->reactive()
->searchable()
->required(),
Select::make('option2')
->options(fn(Get $get) => $this->loadOptions($get('option1')))
->visible(fn(Get $get) => !is_null($get('option1')))
->lazy()
->required(),

private function loadOptions(string $slum) : array
{
if($slum === 'ipsum') {
return [
'football' => 'football',
'american' => 'american'
];
} else if($slum === 'lorem') {
return [
'tennis' => 'tennis',
'hockey' => 'hockey'
];
}
return [];
}
Select::make('option1')
->options([
'ipsum' => 'ipsum',
'lorem' => 'lorem',
])
->reactive()
->searchable()
->required(),
Select::make('option2')
->options(fn(Get $get) => $this->loadOptions($get('option1')))
->visible(fn(Get $get) => !is_null($get('option1')))
->lazy()
->required(),

private function loadOptions(string $slum) : array
{
if($slum === 'ipsum') {
return [
'football' => 'football',
'american' => 'american'
];
} else if($slum === 'lorem') {
return [
'tennis' => 'tennis',
'hockey' => 'hockey'
];
}
return [];
}
The searchable() makes sure visible & options is not working anymore because the Get will not get the value passed in the field.
2 replies
FFilament
Created by Bart_ on 12/14/2023 in #❓┊help
Next page Wizard
No description
4 replies