Setting searchable select field to null not working

I've got the following fields where the first field sets other select fields to null if the selected option gets changed.
Forms\Components\Select::make('sender_id')
->label(__('Sender ID'))
->options(BrevoSenders::pluck('name', 'id'))
->searchable()
->reactive()
->afterStateUpdated(function (\Closure $set) {
$set("email.welcome.template_id", null);
}),
Forms\Components\Select::make("email.welcome.template_id")
->label('Template ID')
->options(fn (\Closure $get) => !empty($get('sender_id')) ? BrevoTemplates::where('sender', $get('sender_id'))->pluck('name', 'id') : [])
->searchable()
->columnSpan('full'),
Forms\Components\Select::make('sender_id')
->label(__('Sender ID'))
->options(BrevoSenders::pluck('name', 'id'))
->searchable()
->reactive()
->afterStateUpdated(function (\Closure $set) {
$set("email.welcome.template_id", null);
}),
Forms\Components\Select::make("email.welcome.template_id")
->label('Template ID')
->options(fn (\Closure $get) => !empty($get('sender_id')) ? BrevoTemplates::where('sender', $get('sender_id'))->pluck('name', 'id') : [])
->searchable()
->columnSpan('full'),
The last field doesn't get set to null correctly if I change the first select. As you can see in the screenshot, it still contains the old value. However, when I remove searchable from the last field, it works correctly. Any idea what's going on? Am I missing a piece of code?
No description
2 Replies
Dennis Koch
Dennis Koch2y ago
Maybe try an empty string?
Arjen
ArjenOP2y ago
That didn't work either. When I click the x in the select field, it shows nothing. With null it at least shows the placeholder. But I shouldn't have to press the x.

Did you find this page helpful?