react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

adding item in array.

Open dilipsingh076 opened this issue 1 year ago • 8 comments

Prerequisites

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 avatar Jul 14 '23 11:07 dilipsingh076

@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.

heath-freenome avatar Jul 14 '23 16:07 heath-freenome

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 : Screenshot 2023-07-17 at 12 00 40 PM Screenshot 2023-07-17 at 12 01 07 PM

  1. 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?

dilipsingh076 avatar Jul 17 '23 06:07 dilipsingh076

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 avatar Jul 18 '23 07:07 dilipsingh076

@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.

heath-freenome avatar Jul 20 '23 18:07 heath-freenome

https://github.com/ds300/patch-package is a better solution then copying the implementation.

MarekBodingerBA avatar Jul 26 '23 14:07 MarekBodingerBA

@MarekBodingerBA Yes, or that.

heath-freenome avatar Jul 28 '23 16:07 heath-freenome

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 avatar Apr 23 '24 17:04 selfesteemteam

@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} />;
}

heath-freenome avatar Apr 23 '24 19:04 heath-freenome