Skip to content

Does not work with flask-admin due to override of formdata #24

Description

@cybertoast

The specific issue is that if wtforms_json is used, the monkey patch does not allow fallthrough/bubble-up of different datatypes.

For example, if using flask-admin and a StringField is overridden on the form as a FileUploadField, the formdata processor will normally parse the provided data, save the file, and store the filename to the StringField. The monkey patch breaks this process since it transforms all input types into their text representation via six:

    if isinstance(self, TextField):
        if self.data is None:
            self.data = u''
        else:
            self.data = six.text_type(self.data)

This is obviously incorrect. I'm not sure about the motivations for this code, so can't say what the correct solution would be. I actually suspect that this block of code should be removed altogether, since it's certainly possible that the back-end should store no value if that's what's received - rather than a blank string. Or it should be handled as the model expects, rather than as overridden text.

I'm happy to submit a pull request, but wanted to first understand what the intentions were.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions