react-jsonschema-form
react-jsonschema-form copied to clipboard
adding item in array.
Prerequisites
- [X] I have read the documentation
What theme are you using?
material-ui
What is your question?
when we add item in array so we found that title of that array items start from zero (0) but i want to change the that title i want the count will be start from 1 how i can do this?
@dilipsingh076 at the moment, there is not an easy way to do this. The HARD way would be to copy the ArrayField
implementation into your code base and update the two lines where the name
is generated with the index. Then you could change the ArrayField
implementation per this documentation. The downside to this is that you will have to keep your implementation in sync with ours.
We'd welcome a feature that allows this naming scheme to be updated in a more customized way.
Hello @heath-freenome sorry for delay but i think i am unable to tell you my problem here i am adding some screen shots please go through these screen shots. please re-open the #3769.
Questions :
- you can see in that screen shot there is a list of string json-schema is create so when i click on add icon you can see the another screen shots there items got added in ui but the label name of that item is listofstring-0* and after that when we add it's goes like that 1,2,3..... so on so i want that the label name start with 1 not from 0 so could you please help me in this? how i can do this?
Hello @heath-freenome i think i am unable to tell you my problem here i am adding some screen shots please go through these screen shots. please re-open the https://github.com/rjsf-team/react-jsonschema-form/issues/3769. please response of above issue.
@dilipsingh076 I understand you would like a solution from the RJSF team for this. As I have shared it is possible for you to implement it yourself, although it is not the best solution as you are effectively copying the entire implementation of our ArrayField
class. You are welcome to add a new feature to RJSF to support this.
https://github.com/ds300/patch-package is a better solution then copying the implementation.
@MarekBodingerBA Yes, or that.
Would it not be possible to export the ArrayField
class for others to extend in such cases where they want to override or extend behavior? I'm in a similar such case where my only option is to re-implement the field to achieve the behaviors I want, but it would be much easier if I could simply extend the ArrayField
class with the changes I want, then register and use it like a custom field.
@selfesteemteam If you call getDefaultRegistry()
you should be able to pull out the ArrayField
implementation and then wrap it with your own CustomArrayField
by calling it.
import { FieldProps } from '@rjsf/utils';
import { getDefaultRegistry } from '@rjsf/core';
const { fields: { ArrayField } } = getDefaultRegistry();
export default function CustomArrayField(props: FieldProps) {
// Do your thing to modify props
return <ArrayField {...props} />;
}