Feedback (AppForm; unmount; proxy; context) #1677
Replies: 1 comment
-
Hey! Thanks a lot for the feedback. I'll note them down for future fixes and features. I can share some insight into why the decisions were made and why the API is the way it is now. They're in no particular order and don't serve as criticism of the feedback here.
We don't currently have an
AppForm is merely a context provider. Making it bound to an HTML element can prove to be problematic if your structure depends on the form's location (modals, cards etc.) // Allows us to now use any form components within
return <form.AppForm>
<form.BlockNavigationIfDirty /> {/* ranging from general logic features */}
<form.Form> {/* to mimicking form elements (and populating its `onSubmit` handler automatically */}
</form.Form>
</form.AppForm>
Yes, the current API will be more wordy. However, consider that the UI logic and form logic are separated by their concerns this way: // Logic for validation, linked fields, name. Related to the form
<form.AppField
name="name"
validators={{}}
listeners={{}}
>
{field => {
// Logic for UI, rendering.
return (<field.Input label="Name" />)
// If we rarely have different fields, we can go for large components:
return (<field.Input label="Name" />)
// Or if you prefer granular control, you can make small field components sharing one field
return (
<field.Item>
<field.Label>Name</field.Label>
<field.Control />
<field.Description>Your name</field.Description>
<field.Message />
</field.Item>
)
}}
</form.AppField>
This discussion has been brought up before, and I frankly agree that it's inconsistent. We'll see if this changes in the future (or perhaps gets overhauled for a v2), but know you're not alone in thinking this. One issue that results from this is that Keep in mind that this is related to <MyFieldGroup form={form} fields={{
foo: 'actual.location',
bar: 'differently.named.in.this.form'
}}
/>
// So if remapping is allowed, then what is this?
<MyFieldGroup form={form} fields="location" />
// Simple, the above string is a shortcut for the following object:
fields={{
foo: 'location.foo',
bar: 'location.bar'
}} I hope this can help clear up some questions you may have had. I'll also consider the feedback here for #1606 , since I wasn't sure how to approach this properly. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Amazing library, thank you!
I do see some boilderplate that from the first glance seems to be like it could be removed somehow:
Here's how I'd like to see it:
Also, when I select a non-special type so that the special group is not rendered but then I select it again so that it is rendered again, I get this error, should I do something differently?
Side note with very low confidence: since we're wrapping the whole thing in
form.AppForm
, couldn't the children resolve theform
instance automatically viauseFormContext
or something? I don't know if type inference will work though.Beta Was this translation helpful? Give feedback.
All reactions