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

Add <Field /> component to render a single field outside of a form #4371

Open
1 task done
ferretwithaberet opened this issue Nov 8, 2024 · 3 comments
Open
1 task done
Labels
feature Is a feature request wontfix

Comments

@ferretwithaberet
Copy link

ferretwithaberet commented Nov 8, 2024

Prerequisites

What theme are you using?

antd

Is your feature request related to a problem? Please describe.

I would love the ability to render a singular field using RJSF. This would be useful for places where you are supposed to give in a singular field.
For example, using ant design pro components's ProTable, if you want to specify the filter component (component shown in the filter form above the table) you have to specify one singular component that takes care of filtering that column of data, but I want to request this data from the backend as a JSON schema (and UI schema) and render the fields based on what the backend gave me.

Describe the solution you'd like

I would see this done through 3 components:

  • RJSF Provider;
  • RJSF Form;
  • RJSF Field.

The <Provider /> component would provide common logic to both Form and Field (like the available widgets).

The <Form /> component would work as it works right now, except, if it has a provider above it, it will take some props from there (like widgets).

The <Field /> component would take a schema (and an UI schema) for a single field, for example:

{
  "type": "integer",
  "min": 1,
  "max": 5
}

and a UI schema like

{
  "ui:widget": "stars",
  "ui:color": "yellow"
}

and render a singular field.

Describe alternatives you've considered

Creating my own mapping of components that I allowed my backend to render.

@ferretwithaberet ferretwithaberet added feature Is a feature request needs triage Initial label given, to be assigned correct labels and assigned labels Nov 8, 2024
@heath-freenome heath-freenome added wontfix and removed needs triage Initial label given, to be assigned correct labels and assigned labels Nov 22, 2024
@heath-freenome
Copy link
Member

@ferretwithaberet The simplest approach for you to use is the tagName property on Form. If you set this to span or div you can use it to simply generate the inputs. No need for the complex design you are asking for.

@ferretwithaberet
Copy link
Author

ferretwithaberet commented Nov 29, 2024

@ferretwithaberet The simplest approach for you to use is the tagName property on Form. If you set this to span or div you can use it to simply generate the inputs. No need for the complex design you are asking for.

My issue with this is that ProTable wraps it's form items in ProForm.Item, so then I would have the label added by ProTable's ProForm.Item and the one from Form.Item from @rjsf/antd. I will look into a way to provide noStyle to the Form.Item inside of RJSF and make a PR if I have the time for it.

@heath-freenome
Copy link
Member

@ferretwithaberet Since the Form.Item compenents are in Templates, you could provide your own override versions of them without needing to update RJSF directly. See the Custom Templates documentation for more details

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

No branches or pull requests

2 participants