Standard way to inject field error?

I have ViewField::make('payment_method_id') whose custom view runs some custom JavaScript. If the custom javascript reports back an error I want to inject the error into the payment_method_id field so that it displays like all other errors do. Is there a generic built in way to do this? ChatGPT tells me I have to create my own (see below example), but it seems like something so common that there would be built in functionality for it. catch (error) { Livewire.dispatch('set-error', { field: 'payment_method_id', message: error.message, }); } and: #[On('set-error')] public function setError($field, $message): void { $this->addError($field, $message); }
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?