Exceptions from Model
Hi, how are you handling when you submit a Filament form, and the Model has a saving function that blocks the saving??
For example, I trigger a ValidationException in the saving function (Model), and Filament doesn't show any alert or message
10 Replies
No one handles Model exceptions?
Have you enabled database transactions ?
Or maybe (additionally?) in combination with
->failureNotificationTitle('Whoops')
on the given action 🤔I never validated anything in my model. I think the data should be validated before.
And when you have validations in both controllers and filament panel? Two different validations?
What is the use case of 2 different validations.?
I could be wrong but the db can only store one type per field.
User signup (api controller) and register user through panel (not admin, website user). Or any other situation where you have api controller and panel resource doing the same
But the data is the same right? So just create a set of validation rules that can be plugged into both places. It’s still just an array of validation rules.
But, that could still just be a static method on the model that returns the array.
But plug-in external validator (e.g. class that returns array of validation rules) into whole Filament form is not possible, so using the same validation rules between diffrent entrypoints (filament, api, external form) can be quite tricky.
Exactly, that's what I mean, and I like to rely on the Model validation, that's should be extended to Filament, but Filament is not reporting feedback about the validation on the Model
Probably you can overwrite getValidationRules() in CreateRecord/EditRecord class and handle there own logic for validation logic.