Closed ghigt closed 2 years ago
You can't use a widget for array fields. Try either the ArrayFieldTemplate
prop or the ui:ArrayFieldTemplate
attribute in the uiSchema.
We thought about using an arrayFieldTemplate in the case where there is no enum attribute but our issue is that it doesn't seem possible to reference an ArrayFieldTemplate with its name in the uiSchema.
As opposed to widgets that supports something like { ui:widget: 'MyWidget' }, arrayFieldTemplate only accepts a component which is quite problematic when you want to serialize the uiSchema.
Would it be interesting to extend the way widgets are handled to arrayFieldTemplates ?
Hi!
I'm working in the same team as @ghigt.
We would be pretty happy to propose a PR to implement the use case he explained above if you think it is interesting for the project, i.e.
Allowing the customizations of non
enums
, nonuniqueItems
array fields in the ui:schema while keeping it serializable.
However it is not clear what would be the best way to do this between:
ui:ArrayFieldTemplate
attribute and creating a util function similar to getWidget
named getArrayFieldTemplate
that will supports both components and templates registered in the registry.renderNormalArray
to support the definitions of a custom widget through ui:widget
the same way it is done in renderMultiSelect
Thanks :)
Oh, I see -- although it's possible to do this using a custom ArrayFieldTemplate, allowing for ui:widget
would parallel the current use of ui:widget
when having an array field with enums or uniqueItems.
So please go ahead with doing that! The second option (modifying renderNormalArray
) seems like it would definitely work and be the most straightforward way to do so.
Hello guys. Has this been implemented? I serialize schemas to json and save them to database. At the moment setting of array template at field level doesn't work for me - obviously component can't be serialized: "ui:ArrayFieldTemplate": MyArrayFieldTemplate
Hi, would like to know if and when this would be prioritized. We have a need where we want to use a custom MultiSelect
widget, that allows a user to select multiple values, so we would like the type to be array
. Currently, we are unable to use type array
and specify a Custom Widget without specifying the enums. We would like to be able to specify CustomWidget
for ui:widget
and for type array
without needing to specify enum
or uniqueItems
to true
@epicfaace to add on to the point above ☝🏾
Is https://github.com/rjsf-team/react-jsonschema-form/pull/2125 the right approach to resolve this issue? If yes, are you accepting PRs? Maybe we can pick it up to close this one out.
I think so -- made a review to #2125.
@epicfaace - Not a huge fan of the approach on https://github.com/rjsf-team/react-jsonschema-form/pull/2125 so created https://github.com/rjsf-team/react-jsonschema-form/pull/2697. Would you mind taking a look?
Thanks -- do you mind adding it to the weekly meeting agenda? I think a synchronous review would be easiest -- https://github.com/rjsf-team/react-jsonschema-form/issues/2677
Prerequisites
Description
Why is it not possible to specify a custom widget for array fields with no
enums
oruniqueItems
set to true? I would like to create 2 widgets:enum
).uniqueItems = false
).Steps to Reproduce
enum
oruniqueItems
in itsitems
.const uiSchema = { "ui:widget": "myCustomWidget" }