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 erroneous validation error #6371

Conversation

smithellis
Copy link
Contributor

Description of Fix for PR

Issue: When initially visiting the edit_avatar view, a field validation error about the avatar field being required is shown, even though the form has not been submitted.

Fix: The issue was caused by the form being instantiated with request.FILES even on a GET request, which triggered the validation logic prematurely. The fix involves modifying the edit_avatar view to ensure that the form is only instantiated with request.POST and request.FILES when the request method is POST.

Changes Made:

  1. Updated the edit_avatar view to check the request method. If the request method is POST, the form is instantiated with request.POST and request.FILES. If the request method is GET, the form is instantiated without request.POST and request.FILES.
  2. Ensured that the form validation logic is only triggered when the form is actually submitted (POST request).
@smithellis smithellis force-pushed the 2055-only-show-validation-error-when-appropriate branch from d15e4f0 to 995a360 Compare November 22, 2024 21:19
@smithellis smithellis merged commit 23dd823 into mozilla:main Nov 25, 2024
2 checks passed
@smithellis smithellis deleted the 2055-only-show-validation-error-when-appropriate branch November 25, 2024 12:22
smithellis added a commit to smithellis/kitsune that referenced this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants