Skip to content
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

adding item in array. #3769

Open
1 task done
dilipsingh076 opened this issue Jul 14, 2023 · 8 comments
Open
1 task done

adding item in array. #3769

dilipsingh076 opened this issue Jul 14, 2023 · 8 comments
Labels
feature Is a feature request help wanted

Comments

@dilipsingh076
Copy link

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 dilipsingh076 added needs triage Initial label given, to be assigned correct labels and assigned question labels Jul 14, 2023
@heath-freenome
Copy link
Member

@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 heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Jul 14, 2023
@heath-freenome heath-freenome added awaiting response possibly close To confirm if this issue can be closed labels Jul 14, 2023
@stale stale bot removed the possibly close To confirm if this issue can be closed label Jul 14, 2023
@dilipsingh076
Copy link
Author

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
Copy link
Author

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 #3769. please response of above issue.

@heath-freenome
Copy link
Member

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

@MarekBodingerBA
Copy link
Contributor

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

@heath-freenome
Copy link
Member

@MarekBodingerBA Yes, or that.

@selfesteemteam
Copy link

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.

@heath-freenome
Copy link
Member

heath-freenome commented Apr 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request help wanted
Projects
None yet
Development

No branches or pull requests

4 participants