-
Notifications
You must be signed in to change notification settings - Fork 309
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
More form updates #5678
More form updates #5678
Conversation
242ff1c
to
7306081
Compare
Based on all the recent work on improving and extending our form logics, I also created the following best practices:
|
Summary
This PR extends the
<Form />
and<Form.Field />
components more to enable advanced use cases that we require for implementing new end device onboarding (#4847)Changes
_
fields).valueSetter
prop to fields which allows for full control over how a field updates form values. This is useful when a field can modify values of other independent fields, e.g. to change a value that would otherwise become invalid due to value constraints. What is important here is that this allows values to change in one single update rather than consecutively like when usinguseEffect()
to hook into form value changes.hiddenFields
prop, to avoid stripping such fields when cleaning the form values during submit._
)validateAgainstCleanedValues
needs to be used. This is only done for backwards compatibility until we refactored fields to always work with cleaned values.Testing
I tested this heavily on the device onboarding branch. The existing e2e should verify that there are no issues with backward compatibility.
Regressions
Possible since this touches on forms.
Notes for Reviewers
Composite fields are a really nice and idiomatic way to enable complex form value modifications without the need of intermediate logic:
Observe the following:
name
properror
's andtouched
-state is automatically mapped back to the corresponding fieldChecklist
README.md
for the chosen target branch.CHANGELOG.md
.CONTRIBUTING.md
, there are no fixup commits left.