Form Actions
Sync Value
🚧

Under Construction This component is a work-in-progress.

Sync Default Values

Used to sync the value of the wrapped input to another input. Will stop syncing once a manual selection is made on the wrapped field. Use case: matching the default value of an end date to the start date since the end date is always after the start date.


Current Status

  • Syncs the value of the wrapped input to another input until a manual selection is made on the wrapped field.

Future

  • Add support for conditions such as strict matching values between fields

Examples

TBD

How to use

Create component

Copy the code from the sandbox above and paste it into a new file (e.g. SyncDefaultValue.tsx)

Add dependent components

Needs Field component and a child component like Date Pick

yourform.tsx
  <SyncDefaultValue
    name="exampleDatePickEnd"
    syncDefaultWith="exampleDatePickStart"
  >
    <Field name="exampleDatePickEnd" defaultValue="">
        <Field.GroupLabel type="standard">End date:</Field.GroupLabel>
        <Field.Control>
            <DatePick startYearRange={1992} endYearRange={2025} />
        </Field.Control>
    </Field>
  </SyncDefaultValue>

Setup defaultValues and zodSchema in Form

Details in Form component

Component API

Required PropTypeDescription
namestringName of the wrapped field. This will be synced to the value of the syncDefaultWith input
syncDefaultWithstringName of the field to sync with.
childrenField or WatchFieldProvides input functionality
Optional PropTypeDescription

Usage Notes