-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Render empty array item fields when minItems is specified #434
Comments
This is closed by #484. |
New features * Add support for rows attribute of textarea widget. (#450) * #434 - Render empty array item fields when minItems is specified (#484) * Add a "has-danger" class to the form error list (#502) * Show description for boolean fields (#498) * Fix #488: Add a custom Form ErrorList prop. Bugfixes * Fix impossibility to use stateful ArrayFieldTeplate comp. (#519) * Centralized shouldComponentUpdate handling in SchemaField (#490)
Released in v0.44.0. |
I recently upgraded from 0.43.0 to 0.45.0 and it seems that this change causes unexpected behaviour in my application: I have defined an array with minItems: 1 but this array is NOT marked as required. This will cause validation errors when submitting again without changing anything, since the changed default behaviour produces invalid state. Could you please add an additional check respecting the required property before applying the newly introduced default behaviour? |
In my own understanding of the JSON schema spec, {
type: "object",
properties: {
foo: {
type: "array",
items: {type: "number"},
minItems: 1
}
}
} And both Edit: Oh I see what you mean, Edit2: I was using |
I'm having a problem with this change too. We're using an array with It can be seen easily in the playground, under Arrays. Add Now click one of the checkboxes in the live demo and see what happens to the formData. A null entry is added after the selected values. Make it I thought that I could set a default for the field, by adding It seems like minItems is serving two different purposes here. And perhaps default too. Perhaps So my only option, unless I'm missing something, is to programmatically initialise the formData to be an empty array where I find an array type in the schema. |
I think I'll post my comment above as a new issue, it looks like a bug to me, and this issue has already been closed. [Edit: This is now posted as #534.] |
When
minItems
is specified for an array field, we should initialize the form with as many empty fields as the number specified.The text was updated successfully, but these errors were encountered: