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 when form has field named method #210

Closed
wants to merge 1 commit into from
Closed

Conversation

markmono
Copy link
Contributor

@markmono markmono commented Mar 18, 2023

If a form has a field named method, an error will occur in the isFormValid function.

fetch(form.action, {
headers: headers,
method: form.method, # Changing this to form.getAttribute('method') fixes the issue.
body: new FormData(form),

forms.py
class FormWithMethodField(BSModalForm):
method = forms.CharField()

views.py
class FormWithMethodForm(BSModalFormView):
template_name = 'form.html'
form_class = forms.FormWithMethodField

Javascript error: Uncaught (in promise) TypeError: Window.fetch: Invalid request method [object HTMLInputElement]. As it's passing the HTML element for name="method"

@trco trco self-requested a review May 1, 2023 15:09
@trco trco mentioned this pull request May 1, 2023
@trco
Copy link
Owner

trco commented May 1, 2023

This PR was merged in #216. Thanks @markmono for your contribution.

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

Successfully merging this pull request may close these issues.

None yet

2 participants