Skip to content

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.

2 participants