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
I'm curious, what is the issue behind this?
Saade
Saade2y ago
You don’t need to disable key while typing on name, afterStateUpdated will update the key before the user can type on it

Did you find this page helpful?