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

[Form Validation] Fix validation when multiple fields has the same name (#6368) #6370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

prudho
Copy link

@prudho prudho commented May 3, 2018

On multiple field with the same name (aka input array), the rule function test multiple times the first value instead of testing each value one time.

This PR allow correct testing of each input with the same name, which fixes #6368.

y0hami pushed a commit to fomantic/Fomantic-UI that referenced this pull request Jan 22, 2019
If a form uses array inputs by appending brackets to their names ( `name="myfield[]"`) the validation on those fields was always done for the whole field group. Means, if the first field was valid, it validated for the whole group which is wrong.
This behavior is now fixed, so even if multiple input fields have the same name to act as array inputs, the validation is done on each field separately and also the error class is set/removed to each field individually.
@prudho was already providing a [PR for that in SUI](Semantic-Org/Semantic-UI#6370) some time ago, but the individual error display handling was missing there.

Hint: If you ask yourself while reviewing, why i added an `internal` parameter to the `add.prompt()`and `validate.rule()` functions: This is to make sure those functions are still callable  as behavior from separate JS (for example: `$('.foo').form('validate rule', argumentOne, argumentTwo)` so they do not break existing code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Input array validations not working at all in forms
1 participant