validation messages under fields not showing
Hi, I have CreateCompany Form component, and validation&model creation is in separate Action CreateCompany. Data is being held in livewire Component $company variable using ->statePath('company'). Problem is - validation is happening for name, website, but filament expects validation messages for company.name company.website. Can I get around this in an easy way, or do I have to do some sheananigans?
Related code:
And here is validation messages working for company., but not showing without company. Also probably should mention that if i add company. to Validator, it doesn't work 🙂
And here is validation messages working for company., but not showing without company. Also probably should mention that if i add company. to Validator, it doesn't work 🙂
7 Replies
Why u validating separately? Just add related rules to each form fields. Filament will handle everything for u.
I know about this, but I don't want to duplicate creation logic in 2 places, if that wasn't the case I'd probably use it already.
Just method or function the logic to be re-used.
It is reusable(at least it was until I remade the component to filament :D). I just don't have any simple idea to get validation messages to work correctly.
I could possibly change validation error names after it fails, but it will be tedious task to do it in every form. I'm asking, since I might be missing something, and it also does not seem like it should be happening.
You may try this.
I tried something like this before, if you do it like this validation messages are shown, but validation itself doesn't work
That is, the property "name" is being validated, but errors are being shown for "company.name" property
Maybe there is a way to set a name, for which the errors are shown?
Or so that I can validate for company.name, and it will both validate & show errors