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

[3.x] Fix persistance of validation errors in forms #8262

Merged

Conversation

PerryvanderMeer
Copy link
Contributor

This PR fixes the problem described in discussion #8168.

Problem

When validating a single property in a form, validation errors for other properties won't persist and will disappear.

Cause

Validating forms differs slightly from validating normal properties. When validating normal properties, we merge in existing validation errors:

invade($e->validator)->messages = $messages->merge(
$this->errorBagExcept($ruleKeysForField)
);

When validating properties in a form, we do not.

Solution

We can merge in existing validation errors when validating form properties via validateOnly().

@calebporzio
Copy link
Collaborator

This is perfect - good catch! Thanks!

@calebporzio calebporzio merged commit 94249d1 into livewire:main Apr 5, 2024
3 of 5 checks passed
@PerryvanderMeer PerryvanderMeer deleted the persist-validation-errors-in-forms branch April 5, 2024 14:47
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.

None yet

2 participants