Skip to content

Dynamically Update one field based on another field #1281

Answered by kestarumper
austinh asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @austinh,

Reacting to field changes

If the user changes valueA to be 2 I want to update valueB to be twice as much as valueA (so valueB is valueA * 2). However, the user could still modify valueB after the fact. It would be a nice helper based on some selections the user picks.

There are a few approaches to this, but there is one limitation for sure - you can't achieve this using schema only. This needs to be handled in the implementation. Let's review a few possibilities that we have:

Overriding AutoForm.onChange - from the form perspective

You can override the onChange by extending the AutoForm class and reacting to particular field key changes.

With custom field(s) (useField twice…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by austinh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants