ErrorBag Definition
chellmann opened this issue · comments
Hello,
thank you very much for your work and willing to share it.
Is it possible to set the ErrorBag in the x-form element? It would be useful when displaying more than one form on a single page.
Thanks
Do you mean something like this?
<x-form error-bag="login">
{{-- --}}
</x-form>
<x-form error-bag="register">
{{-- --}}
</x-form>
Yes, exactly this.
With the recent support for error bag should be fixed also for single input hasError() like here:
The check must be:
@error('field', 'errorBagName') is-invalid @enderror
Setting error bag on form level would be better to avoid to pass bag name to each component
I added that in preparation for solving this issue :)
A Blade Component can't access their parent's data because the compiler renders the children/slots before the parent. Marcel is working on a PR to support this. Whenever that gets merged, we'll be able to do bindings and setting the bag on the x-form
element:
<x-form error-bag="profile" :bind="$user">
<x-form-input name="biography" />
</x-form>
I'll leave this issue open until then.