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:Jump to solution
probably the
getStatePath()
. You can try $this->addError('data.code', 'Invalid code')
Share the whole code please...2 Replies
Solution
probably the
getStatePath()
. You can try $this->addError('data.code', 'Invalid code')
Share the whole code pleasePerfect thanks, this worked π