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

fix: avoid double validation of submit form #834

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

EdoStorm96
Copy link
Contributor

@EdoStorm96 EdoStorm96 commented Jan 6, 2025

So, the fix you suggested, @miggol:

When validating the submit form using the stepper, if only the submit form has an error, we don't add an extra error, as this can cause the form to get stuck, because it is unable to save.

Nothing fancy.

This does kindoff showcase why having Stepper.get_form_errors() return a list of dicts was a bit of a bad idea ... my bad hehe

@EdoStorm96 EdoStorm96 requested a review from miggol January 6, 2025 15:09
Copy link
Contributor

@miggol miggol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If matching the URL works just as well, I would prefer that. But otherwise approved!

if form_errors:
# If there are only errors on the submit form, we override this
# validation. Otherwise saving the updated data becomes impossible
if len(form_errors) == 1 and form_errors[0]["page_name"] == _("Indienen"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works surprisingly well, but I would much rather have a test like

"proposals/submit" in error["url"].lower()"

The URL just feels a lot more dependable.

@EdoStorm96 EdoStorm96 merged commit de1d912 into major/4 Jan 8, 2025
3 checks passed
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