-
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
Appending arbitrary fields to form? #171
Comments
Yes, we'd need support for anyOf/oneOf to achieve this "automatically". It should be possible to create a custom SchemaField, where you can hook into the way JSON schemas are mapped to field components, but this is likely to be pretty tricky... |
Another strategy would be to generate a new schema with the new field added. The flow would be:
Might be worth a try. |
That's a good idea, I'll give that a shot. I was going to try just adding a new |
That'd move the complexity to listening to many Form |
Just wanted to let you know that your suggestion above was pretty much exactly what I needed. I have a form that's separate from the one that I'm building up that allows the user to select which field they'd like to add to the form. Each selection has a schema associated with it, so when the user selects a field, I add that field's schema to the form schema and re-render the form. I'm relatively new to React so the "update state then re-render" cycle wasn't very intuitive to me, though the solution seems fairly obvious now. |
I'm glad you found a solution to your problem using the current API. I'm closing this now, and if you have any pointer to your implementation, feel free to link it here so other people can take inspiration :) |
I'd like to achieve functionality similar to the Add/Delete buttons on arrays, but instead of adding the same field to the form every time the button is clicked, I'd like the user to be able to add a field from an arbitrary list of fields.
Would something like this require support for
oneOf
(#52)? Would this be possible to do by creating a custom field?The text was updated successfully, but these errors were encountered: