Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorBag() form option #134

Merged
merged 3 commits into from
Aug 13, 2024
Merged

errorBag() form option #134

merged 3 commits into from
Aug 13, 2024

Conversation

cheyner
Copy link
Contributor

@cheyner cheyner commented Aug 7, 2024

Support for setting the error bag will make it possible to render multiple forms on a single page that have independent error handling. As it stands, if each of those forms had -- for example -- a summary() element, they would all indicate an error if there were a validation error in any form that had been submitted.

To link up server side validation with your Aire form, you would do the following:
$request->validateWithBag('custom_bag', [
'somefield' => 'required'
])

And in Aire:
Aire::open()->errorBag('custom_bag')

Didn't add a test -- not yet setup to run tests for this project and it perhaps wasn't clear the best place for that test to live. Maybe ServerValidationTest.php.

@cheyner cheyner changed the title errorBag() method/functionality errorBag() form option Aug 7, 2024
@inxilpro
Copy link
Contributor

inxilpro commented Aug 7, 2024

I can definitely see using this. Would something like useErrorsFrom maybe make more sense?

Aire::open()->rules(...)->useErrorsFrom('secondary-bag');

@cheyner
Copy link
Contributor Author

cheyner commented Aug 7, 2024

I don't mind a different method name along those lines, but I think mentioning "bag" in the name would require less cognition.

@inxilpro inxilpro merged commit 054766a into glhd:main Aug 13, 2024
23 checks passed
@cheyner cheyner deleted the error-bags branch August 13, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants