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

Changing name causes data to silently not be returned #438

Closed
thekevingibbons opened this issue Aug 1, 2018 · 1 comment
Closed

Changing name causes data to silently not be returned #438

thekevingibbons opened this issue Aug 1, 2018 · 1 comment

Comments

@thekevingibbons
Copy link

In wtforms/src/wtforms/fields/core.py (as of writing, lines 333-337):

if formdata is not None:
    if self.name in formdata:
          self.raw_data = formdata.getlist(self.name)
    else:
          self.raw_data = []

If the code enters the else statement, it silently causes no data to return back from your form without giving an indication as to why. This can occur if you set the name attribute of a field after the instantiation of that field, for example, when one tries to create fields with dynamic names and values.

Suggested fix: throw an error in the else statement that describes what causes your form not to return any data, something along the lines of "The name of this field changed between instantiation and the form being submitted; this is not allowed"

@davidism
Copy link
Member

davidism commented May 16, 2020

I don't think this behavior should change, at least not in the way described here. If you're changing the name after submitting the form, that's a problem you need to fix in your code, as you're not applying it consistently before and after submitting, otherwise the names would match. This seems like a specific case of #402.

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

No branches or pull requests

2 participants