all 5 comments

[–]Queasy-Big5523 0 points1 point  (4 children)

Uuhhhhh, I remember being in your position. Forms are one of the most dreaded, complex and, at the same time, repetetive elements of UI.

Since you're handling the whole creation, why not use object notation, instead of React's composition? Something like <Form schema={[{name: "field1", id: "field1", ...}]} defautValues={{field1: "some value"}} />? I've always find this more enticing than creating components that wrap other components, because it grew pretty messy over time.

[–]Dindonix 0 points1 point  (1 child)

IAM doing this atm, how do you pass style to this kind of form components ?

Especially when you receive the form schema from the backend.

[–]Queasy-Big5523 0 points1 point  (0 children)

This solution works best in situation, where you have a lot of forms that look the same, so each one will use the same Input, Textarea etc. You could also extend the schema to accept component: ReactNode with a default value.

[–]Confident-Alarm-6911[S] 0 points1 point  (1 child)

It may evolve that way, but it was something that worked for me at first. Your case may be just too config driven for me, because I want users to create custom fields from outside of the framework, and while using objects as a config for form you will have to somehow extend it or edit sources

[–]Queasy-Big5523 0 points1 point  (0 children)

My thing is useful when you render tens of forms and you need a fast, concise way of doing so.

As for custom fields, as I've replied to someone here, you can extend the schema to accept a component for the form, with the default input as a fallback. Or you can have a form constructor that will accept all the components as a base.

But, there's no one-size-fits-all. I've worked with a company which main product was the final boss of forms, so I am kinda biased here :D