You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use react-jsonschema-form and need to extend it with more complex conditions, so, I decided to use this extension.
Below is my FormRenderer component where I used to render Form component where FormWithConditionals is now.
I struggle with two things:
In order to use it I have to define a const within my FormRenderer component as shown in the example. So, I do this: FormWithConditionals = applyRules(this.jsonSchema, this.jsonLayout, this.rules_simplified, Engine)(Form);
It looks weird to me: I need to use <**this.**FormWithConditionals> in order to use it. I didn't find a way to have it in a separate file as a standalone component/wrapper and then being imported and used because I don't know how to provide the rest of regular Form props to it (onChange, liveValidation and so on..). My attempt below obviously fails because when I try to use it in FormRenderer where Form used to be it complains about all the rest of usual Form parameters. Does it mean that defining it as a const and then using with <this.FormWithConditionals is the only way to do it?
My second issue is that with the approach above I cannot use shcema and layout from props. Notice that when I create the component in applyRules method I use constants for schema and uiSchema instead of props as I used to do before for Form component. I had to do it this way because when I tried to get them from props this.props.jsonSchema and this.props.jsonLayout rule engine failed at validation step. It seems that at initial rendering they are provided with empty values, and rule engine fails at rules validation because it cannot find the field which I refer in rule's remove event. When I use hardcoded constants instead of props with the same values as in props - it works becuse everything is provided at once. Could you suggest any solution for this?
Hello.
I use
react-jsonschema-form
and need to extend it with more complex conditions, so, I decided to use this extension.Below is my
FormRenderer
component where I used to renderForm
component whereFormWithConditionals
is now.I struggle with two things:
FormRenderer
component as shown in the example. So, I do this:FormWithConditionals = applyRules(this.jsonSchema, this.jsonLayout, this.rules_simplified, Engine)(Form);
Then I render it like this:
It looks weird to me: I need to use
<**this.**FormWithConditionals>
in order to use it. I didn't find a way to have it in a separate file as a standalone component/wrapper and then being imported and used because I don't know how to provide the rest of regular Form props to it (onChange, liveValidation and so on..). My attempt below obviously fails because when I try to use it inFormRenderer
whereForm
used to be it complains about all the rest of usualForm
parameters. Does it mean that defining it as a const and then using with<this.FormWithConditionals
is the only way to do it?applyRules
method I use constants forschema
anduiSchema
instead of props as I used to do before forForm
component. I had to do it this way because when I tried to get them from propsthis.props.jsonSchema
andthis.props.jsonLayout
rule engine failed at validation step. It seems that at initial rendering they are provided with empty values, and rule engine fails at rules validation because it cannot find the field which I refer in rule's remove event. When I use hardcoded constants instead of props with the same values as in props - it works becuse everything is provided at once. Could you suggest any solution for this?Full code:
The text was updated successfully, but these errors were encountered: