Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

ErrorBag Definition #19

Open
chellmann opened this issue Oct 7, 2020 · 4 comments
Open

ErrorBag Definition #19

chellmann opened this issue Oct 7, 2020 · 4 comments

Comments

@chellmann
Copy link

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

@pascalbaljet
Copy link
Contributor

Do you mean something like this?

<x-form error-bag="login">
    {{--  --}}
</x-form>

<x-form error-bag="register">
    {{--  --}}
</x-form>

@chellmann
Copy link
Author

Yes, exactly this.

@thewebartisan7
Copy link

With the recent support for error bag should be fixed also for single input hasError() like here:

https://github.com/protonemedia/laravel-form-components/blob/master/resources/views/bootstrap-4/form-input.blade.php#L13

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

@pascalbaljet
Copy link
Contributor

pascalbaljet commented Oct 22, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants