You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently on the python side we misuse a fields default value: for injecting the data on Form that are used to edit stuff.
This has a side effect: all form fields that have data, have a default -> so are not required anymore.
Currently we work around this with extra validators, which is error prone and leads to code duplication in cases where you have a Create and Edit Form.
Solution direction:
it would be nice to embed the form data in the JSON scheme
check if it possible to use the "uniforms" as a nested dict in the form field property: to provide the data (see screen, which shows an extra "value" key.)
if 2 is not possible: try to return the data inside the JSON scheme on another location: frontend will need changes to populate the fields
Questions:
what to do with edit form when no data can be found for a field; but a default does exist on the form definition?
The text was updated successfully, but these errors were encountered:
acidjunk
changed the title
When prepopulating forms with data
Form that show data; override/misuse the default value -> which makes all fields that have data NOT REQUIRED
May 4, 2023
I fiddled a bit with some forms. Best way forward seems to be to delegate form data loading to the JS part, instead of polluting our pydantic models with defaults that hold the value.
This works for all fields, except for "str": when you edit a pre-poulated string field: uniforms submits: "" -> which pydantic considers a valid string. When a required field isn't populated at all with data: a submit doesn't have this field in the payload: and that triggers a required validation.
Currently on the python side we misuse a fields default value: for injecting the data on Form that are used to edit stuff.
This has a side effect: all form fields that have data, have a default -> so are not required anymore.
Currently we work around this with extra validators, which is error prone and leads to code duplication in cases where you have a Create and Edit Form.
Solution direction:
Questions:
The text was updated successfully, but these errors were encountered: