Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Form fields with "disabled" get sent to the server #138

Open
gergelypolonkai opened this issue Jun 12, 2015 · 3 comments
Open

Form fields with "disabled" get sent to the server #138

gergelypolonkai opened this issue Jun 12, 2015 · 3 comments

Comments

@gergelypolonkai
Copy link

Most (all?) browsers exclude disabled form fields (e.g. <input type="text" name="whatever" disabled>) from the form data they send during form submission. However, webtest doesn’t do this, which made several tests of mine fail. Is there a way to mimic this behaviour?

@gawel
Copy link
Member

gawel commented Jun 12, 2015

I don't think so. But you can provide a patch. Something like .submit(disabled=False) would be great

@nealtodd
Copy link

Four years late to this particular party, but also bitten by this in some tests that were dependent on disabled fields not getting sent on submit.

I don't have time to provide a patch, sorry, but for anyone else coming across this issue here's a quick and dirty fix to use in a test to prune out disabled fields before submitting:

form = my_response_object.forms['my-form']

for name_field_tuple in form.field_order[:]:
    if 'disabled' in name_field_tuple[1].attrs:
        form.field_order.remove(name_field_tuple)

form.submit()

Worked for me as I didn't need to do anything else with the form object after submitting.

@merwok
Copy link

merwok commented Sep 18, 2019

Something like .submit(disabled=False) would be great

With what behaviour?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants