F
Filament15mo ago
Tom

Realtime field validation.

How can I have realtime validation> I am trying with the following with no success. ->afterStateUpdated(function ($livewire) { $livewire->validateOnly('data.public_key'); })
Solution:
```php Textarea::make('public_key') ->label(__('Public Key')) ->maxLength(255) ->rows(10)...
Jump to solution
4 Replies
SirFat
SirFat15mo ago
Seems to be missing context here - what state is being updated to fire that ?
Tom
TomOP15mo ago
Textarea::make('public_key')
->label(__('Public Key'))
->maxLength(255)
->rows(10)
->required()
->rules([new PublicKey])
->afterStateUpdated(function ($livewire) {
$livewire->validateOnly('data.public_key');
})
Textarea::make('public_key')
->label(__('Public Key'))
->maxLength(255)
->rows(10)
->required()
->rules([new PublicKey])
->afterStateUpdated(function ($livewire) {
$livewire->validateOnly('data.public_key');
})
Solution
LeandroFerreira
LeandroFerreira15mo ago
Textarea::make('public_key')
->label(__('Public Key'))
->maxLength(255)
->rows(10)
->required()
->rules([new PublicKey])
->live(onBlur: true)
->afterStateUpdated(function ($livewire, $component) {
$livewire->validateOnly($component->getStatePath());
})
Textarea::make('public_key')
->label(__('Public Key'))
->maxLength(255)
->rows(10)
->required()
->rules([new PublicKey])
->live(onBlur: true)
->afterStateUpdated(function ($livewire, $component) {
$livewire->validateOnly($component->getStatePath());
})
Tom
TomOP15mo ago
Worked perfectly. I really appreciate it.
Want results from more Discord servers?
Add your server