-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
How to write a material-ui replacer? #832
Comments
I have started working on it. I used the method that provides the widgets and fields props, but It seems I cannot get rid of the <Label component, which should be removed since now it is twice. The label component is rendered in DefaultTemplate and SchemaFieldRender functions inside the SchemaField.js. So it seems like react-jsonschema-form is not ready for custom UIs yet. It would be nice if all components (like <Label etc) would be in the Field or widget, so they could be accessed. But it may be that I am wrong, so I would appreciate any help. Thank you |
@joesanta555 I've done something very similar which has worked quite well. I have a custom Form component that wraps the react-jsonschema-form and passes in all my custom fields and widgets like so:
Note that you can also replace Field and Array field templates to restyle the entire form. |
@llamamoray This is actually very good solution to wrap it. Thank you I just spent couple of days trying to come up with the combination of fields and widgets to pass to <Form to change the design to material-ui including errors and live validation but I am stuck on these:
|
1 - I achieved this by implementing my own ObjectFieldTemplate and passing it into the FieldTemplate prop of Form. You can omit the title field in this component. To give you an idea of what this looks like these are the props types for my custom implementation:
2 - This would require a code change to the project I believe. 3 - PR #826 will cover this for you, I'm waiting for another review of this. |
@joesanta555 with version 1.0.1 the raw errors are passed down to custom controls so you'll be able to achieve point 3. |
What I'd like to see is for each frontend library (bootstrap, material-ui, foundation, etc.) have its own react-jsonschema-form-foo package which provides the components and widgets that rjsf can use to render itself according to that frontend library style. I'm sure there are lots of places where we don't quite support everything we need in order to make this work. For example, maybe we should allow overriding See also #899. I think Bootstrap 4 is going to make this issue be more important. |
Thanks for your pr, I have now access to the raw errors prop. |
@llamamoray the link you mentioned removes errors list for the form, which is rendered upon components. |
@mehrdaad It seems like defining your own FieldTemplate should be enough to let you decide how to handle errors. Is your problem related to the rest of this issue, titled "How to write a material-ui replacer?" If not, consider maybe a separate issue. |
I'm doing as you mentioned right now, but I thought maybe rjsf would have a more automatic way of displaying errors for a field. |
This was added in https://github.com/cybertec-postgresql/rjsf-material-ui, so I'm closing this issue. Also see #1222. |
Prerequisites
Description
Hi, I have read the docu and all the issues about replacing bootstrap with something else. I am willing to write the code that will use replace bootstrap syntax with material-ui components.
What would be the best way to approach it?
One "dirty" idea is to install the npm package and then just replace some files, like src/components/widgets/BaseInput.js and load it on top of the npm package... Would it be the best way? If yes, how to do it?
Another idea is to use the "Customizing the default fields and widgets"... would this be better way?
Thank you
The text was updated successfully, but these errors were encountered: