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

Name prop in custom widget for nested properties #1763

Closed
1 of 3 tasks
Parro opened this issue May 19, 2020 · 2 comments · Fixed by #3470
Closed
1 of 3 tasks

Name prop in custom widget for nested properties #1763

Parro opened this issue May 19, 2020 · 2 comments · Fixed by #3470

Comments

@Parro
Copy link
Contributor

Parro commented May 19, 2020

Prerequisites

Description

If the schema is an object of fields, in the custom Field component there is a name prop (I didn't found it in the doc) that contains the schema property name, while the id prop contains

The tree of unique ids for every child field

as stated in the docs.
In the custom Widget component, I found only id as a string and no name prop, see Codepen https://codepen.io/Parro78/pen/zYvMZVY. name is useful because it is the same name used in the formData object. Could we uniform the behavior adding name in both Field and Widget component?

Expected behavior

If a field is a child of an object field, name is exposed in the props in the Field and Widget components.

Actual behavior

If a field is a child of an object field, name is present only in Field component and undocumented

Version

2.0.1

I made a PR to add the name prop.

@newt10
Copy link
Collaborator

newt10 commented Sep 3, 2021

@Parro can you workaround this by using a custom ObjectField or custom ObjectFieldTemplate?

@Parro
Copy link
Contributor Author

Parro commented Sep 6, 2021

Hi @newt10, I could use a custom ObjectFieldTemplate to inject the name prop for custom Fields and Widgets, but my PR was intended to correct what I thought was an inconsistency in the documentation (name prop already exists in Field but is undocumented). Are there any drawbacks in exposing this prop?

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 4, 2023
Fixes rjsf-team#1763 by adding `name` to `WidgetProps` and ensuring it is passed to all widgets from field implementations
- Updated `@rjsf/utils` to add `name` to the `WidgetProps` type and updated the documentation of `id` to better reflect it being used for `name` and `id` on HTML field elements
- Updated `@rjsf/bootstrap-4` mock creation to provide a `name` on the base `WidgetProps`
- Updated `@rjsf/core` to update `ArrayField`, `BooleanField`, `MultiSchemaField`, `StringField` and `AltDateWidget` to pass the `name` field through to the widgets rendered
  - Updated `BaseInputTemplate` to extract the `name` prop from the rest of the props spread onto the `input` to keep using the `id` as the `name`
- Updated `@rjsf/material-ui` and `@rjsf/mui` to extract the `name` prop from the rest of the props spread onto the `TextField` field in `BaseInputTemplate` and `SelectWidget`
- Updated the `custom-widgets-fields` documentation to add the `name` prop for widgets and to update the `id` documentation
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 4, 2023
Fixes rjsf-team#1763 by adding `name` to `WidgetProps` and ensuring it is passed to all widgets from field implementations
- Updated `@rjsf/utils` to add `name` to the `WidgetProps` type and updated the documentation of `id` to better reflect it being used for `name` and `id` on HTML field elements
- Updated `@rjsf/bootstrap-4` mock creation to provide a `name` on the base `WidgetProps`
- Updated `@rjsf/core` to update `ArrayField`, `BooleanField`, `MultiSchemaField`, `StringField` and `AltDateWidget` to pass the `name` field through to the widgets rendered
  - Updated `BaseInputTemplate` to extract the `name` prop from the rest of the props spread onto the `input` to keep using the `id` as the `name`
- Updated `@rjsf/material-ui` and `@rjsf/mui` to extract the `name` prop from the rest of the props spread onto the `TextField` field in `BaseInputTemplate` and `SelectWidget`
- Updated the `custom-widgets-fields` documentation to add the `name` prop for widgets and to update the `id` documentation
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 4, 2023
Fixes rjsf-team#1763 by adding `name` to `WidgetProps` and ensuring it is passed to all widgets from field implementations
- Updated `@rjsf/utils` to add `name` to the `WidgetProps` type and updated the documentation of `id` to better reflect it being used for `name` and `id` on HTML field elements
- Updated `@rjsf/bootstrap-4` mock creation to provide a `name` on the base `WidgetProps`
- Updated `@rjsf/core` to update `ArrayField`, `BooleanField`, `MultiSchemaField`, `StringField` and `AltDateWidget` to pass the `name` field through to the widgets rendered
  - Updated `BaseInputTemplate` to extract the `name` prop from the rest of the props spread onto the `input` to keep using the `id` as the `name`
- Updated `@rjsf/material-ui` and `@rjsf/mui` to extract the `name` prop from the rest of the props spread onto the `TextField` field in `BaseInputTemplate` and `SelectWidget`
- Updated the `custom-widgets-fields` documentation to add the `name` prop for widgets and to update the `id` documentation
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 5, 2023
Fixes rjsf-team#1763 by adding `name` to `WidgetProps` and ensuring it is passed to all widgets from field implementations
- Updated `@rjsf/utils` to add `name` to the `WidgetProps` type and updated the documentation of `id` to better reflect it being used for `name` and `id` on HTML field elements
- Updated `@rjsf/bootstrap-4` mock creation to provide a `name` on the base `WidgetProps`
- Updated `@rjsf/core` to update `ArrayField`, `BooleanField`, `MultiSchemaField`, `StringField` and `AltDateWidget` to pass the `name` field through to the widgets rendered
  - Updated `BaseInputTemplate` to extract the `name` prop from the rest of the props spread onto the `input` to keep using the `id` as the `name`
- Updated `@rjsf/material-ui` and `@rjsf/mui` to extract the `name` prop from the rest of the props spread onto the `TextField` field in `BaseInputTemplate` and `SelectWidget`
- Updated the `custom-widgets-fields` documentation to add the `name` prop for widgets and to update the `id` documentation
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit that referenced this issue Mar 6, 2023
Fixes #1763 by adding `name` to `WidgetProps` and ensuring it is passed to all widgets from field implementations
- Updated `@rjsf/utils` to add `name` to the `WidgetProps` type and updated the documentation of `id` to better reflect it being used for `name` and `id` on HTML field elements
- Updated `@rjsf/bootstrap-4` mock creation to provide a `name` on the base `WidgetProps`
- Updated `@rjsf/core` to update `ArrayField`, `BooleanField`, `MultiSchemaField`, `StringField` and `AltDateWidget` to pass the `name` field through to the widgets rendered
  - Updated `BaseInputTemplate` to extract the `name` prop from the rest of the props spread onto the `input` to keep using the `id` as the `name`
- Updated `@rjsf/material-ui` and `@rjsf/mui` to extract the `name` prop from the rest of the props spread onto the `TextField` field in `BaseInputTemplate` and `SelectWidget`
- Updated the `custom-widgets-fields` documentation to add the `name` prop for widgets and to update the `id` documentation
- Updated the `CHANGELOG.md` file accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants