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
wtforms provides an alternative to manage several times the same input, with FieldList. However FieldList have some differences:
the input have an incremental suffix, so this makes JS reordering of the fields more complicated for instance
resizing of the data list must be done with append_entry and pop_entry, users cannot directly delete a field in the middle of the list
it allows to nest FormField and make complex forms.
I think wtforms could support multiple fields. For instance we could add a multiple field in Fields with a default value at False, matching the current behavior. If set to Truefield.data would return a list instead of a single value. Validators should validate each individual values.
This could help with the validators handle one single value part of #662
The text was updated successfully, but these errors were encountered:
I've thought about this before, but it feels like we're getting to the point of requiring a huge redesign of the entire library. There are nuances to accepting both single and list, validating each item or the whole list, handling a list of same-named fields where only some where filled out, applying required appropriately, etc. This is partially what I commented about in #662, because the current way we handle data is inconsistent and incomplete compared to what's possible in HTML.
I could not find it clearly written on the specs, but HTML allows an input file to have several values. For instance this is valid HTML:
However, wtforms does not support this, and always consider the first item of the request for a given name (here
bar
).https://github.com/wtforms/wtforms/blob/9f9146c8ee2cb2b2e7b3d9bc09ac7e433fd55bb0/src/wtforms/fields/core.py#L362-L363
wtforms provides an alternative to manage several times the same input, with FieldList. However FieldList have some differences:
append_entry
andpop_entry
, users cannot directly delete a field in the middle of the listI think wtforms could support multiple fields. For instance we could add a
multiple
field inFields
with a default value atFalse
, matching the current behavior. If set toTrue
field.data
would return a list instead of a single value. Validators should validate each individual values.This could help with the validators handle one single value part of #662
The text was updated successfully, but these errors were encountered: