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

In addition to process_form_data, should we have its reverse values_to_form_data? #440

Closed
japsu opened this issue Feb 19, 2024 · 1 comment
Assignees

Comments

@japsu
Copy link
Contributor

japsu commented Feb 19, 2024

The idea of form_data vs. values is to store whatever the user's browser sent in form_data and only convert it on demand to values. form_data is always* dict[str, str] whereas values can be dict[str, str | int | list[str] | dict[str, str]] or even more types.

Currently SchemaFormInput is responsible for understanding the values type of its value (eg. DateTimeField: ISO 8601 string #438, NumberField: number etc.) and making whatever conversion is required to enable an <input> to display it.

Should this conversion be pushed to the backend, or should we expose the raw Response.form_data so that field implementation would be more straightforward <input type={type} value={value}>?

The form_data -> values -> form_data conversion cycle may still be preferred in order to perform satanization.

*) Actually not true due to FileUploadField value in form_data always being list[str] regardless of number of files. So we are already touching the form_data in frontend before it reaches the databae.

@japsu
Copy link
Contributor Author

japsu commented Sep 29, 2024

Can't think of a reason. SchemaFormInput is a good place for it for now.

@japsu japsu closed this as completed Sep 29, 2024
@japsu japsu self-assigned this Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant