F
Filamentβ€’2w ago
frame

FileUpload file validation after upload, before submit

Is it possible to validate a FileUpload field before submit? I can access the uploaded file using afterStateUpdated and similar functions, but is there any function other than rules that has access to $fail? I tried throwing ValidationError, etc but those didn't seem to work.
Solution:
Thanks! πŸ’– I may have gotten it working with
->afterStateUpdated(function (\Livewire\Component $livewire, Forms\Components\FileUpload $component)
$livewire->validateOnly($component->getStatePath())
})
->afterStateUpdated(function (\Livewire\Component $livewire, Forms\Components\FileUpload $component)
$livewire->validateOnly($component->getStatePath())
})
...
Jump to solution
2 Replies
Solution
frame
frameβ€’2w ago
Thanks! πŸ’– I may have gotten it working with
->afterStateUpdated(function (\Livewire\Component $livewire, Forms\Components\FileUpload $component)
$livewire->validateOnly($component->getStatePath())
})
->afterStateUpdated(function (\Livewire\Component $livewire, Forms\Components\FileUpload $component)
$livewire->validateOnly($component->getStatePath())
})

Did you find this page helpful?