F
Filament17mo ago
gizmojo

Disable field while performing 'set'

Can Alpine be used to add a disabled attribute to a field while it's being updated?
Forms\Components\TextInput::make('name')
->afterStateUpdated(function (\Closure $set, ?string $state) {
if (filled($state)) {
// Temporarily disable the key to prevent any input while it's being updated
$set('key', Str::slug($state));
}
})
->reactive(),
Forms\Components\TextInput::make('key')
Forms\Components\TextInput::make('name')
->afterStateUpdated(function (\Closure $set, ?string $state) {
if (filled($state)) {
// Temporarily disable the key to prevent any input while it's being updated
$set('key', Str::slug($state));
}
})
->reactive(),
Forms\Components\TextInput::make('key')
2 Replies
Patrick Boivin
Patrick Boivin17mo ago
I'm curious, what is the issue behind this?
Saade
Saade17mo ago
You don’t need to disable key while typing on name, afterStateUpdated will update the key before the user can type on it
Want results from more Discord servers?
Add your server