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

Amend InputRequired validator to support multi-input fields #716

Conversation

dalepotter
Copy link

@dalepotter dalepotter commented Dec 5, 2021

Small change to the InputRequired validator, so that it examines the entire contents of field.raw_data for validation logic (rather than just the first element). This is helpful when the HTML representation of a Field renders more than one <input>- e.g. using a widget.

For example, a WTForms implementation of the Gov.UK Design System Date Input component renders three HTML <input> elements. Prior to this fix, missing input in the first (i.e. Day, or raw_data[0]) input triggers a ValidationError, even if data was entered in the second (i.e. Month, or raw_data[1]) and/or third (i.e. Year, or raw_data[2]) inputs.

Commit checklist:

  • add tests that fail without the patch - see 9797106
  • ensure all tests pass with pytest
  • N/A add documentation to the relevant docstrings or pages
  • add versionadded or versionchanged directives to relevant docstrings - see 7a87422
  • add a changelog entry if this patch changes code - see 7a87422

@dalepotter dalepotter changed the title [Draft] InputRequired interrogates entire contents of field.raw_data InputRequired interrogates entire contents of field.raw_data Dec 5, 2021
@dalepotter dalepotter changed the title InputRequired interrogates entire contents of field.raw_data Amend InputRequired validator to support multi-input fields Dec 6, 2021
@azmeuk
Copy link
Member

azmeuk commented Dec 23, 2021

Hi. Thank you for your patch. I am very interested in the subject of wtforms being able to manage several input. This may be related to #662. I think I have to take some time to think of all the implications, so that would be when I am a little less busy. But I do not forget.

@azmeuk azmeuk added the enhancement New feature, or existing feature improvement label Dec 23, 2021
@azmeuk azmeuk self-assigned this Dec 26, 2021
@azmeuk azmeuk removed their assignment Jul 22, 2023
@azmeuk
Copy link
Member

azmeuk commented Oct 10, 2023

I am closing this because at the moment wtforms does not support several inputs with the same name. This might come in the future, but that would require a big overhaul.
Related to #799

@azmeuk azmeuk closed this Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, or existing feature improvement
Development

Successfully merging this pull request may close these issues.

2 participants