F
Filament13mo ago
Harvey

How to add field error manually in Livewire component

I have a custom Livewire component with a form(), and I need to give a field an error message after submission. The field is called "code", and I need to add an error message of "Invalid code" only after they have submitted the form. I assumed I would just do $this->addError('code', 'Invalid code') but I cannot see it, am I missing a prefix or something? Or have I missed something in the docs?
Solution:
probably the getStatePath(). You can try $this->addError('data.code', 'Invalid code') Share the whole code please...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira13mo ago
probably the getStatePath(). You can try $this->addError('data.code', 'Invalid code') Share the whole code please
Harvey
HarveyOP13mo ago
Perfect thanks, this worked 🙂

Did you find this page helpful?