Skip to content

Conditionally set a checkbox as disabled based on another checkbox value #1355

Answered by rvsia
pedlima asked this question in Need help
Discussion options

You must be logged in to vote

Hello,

ReadOnly

You have two options

  1. Have two fields with the same name in schema - one normal, second is readOnly. Use condition to show/hide them based on the value.

  2. Use resolveProps based on different field https://data-driven-forms.org/examples/resolve-props-example#wrapthecomponentinformspy to set disabled/readOnly, please do not do any side effects in resolve props

Remove value from the state

In this case, just remove the value in your submit function.

Alternative

if there is no requirement to make the second checkbox disabled/readOnly, you can use condition together with clearOnUnmnout. Condition will hide the field, clearOnUnmnout will remove the value from the state.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rvsia
Comment options

@pedlima
Comment options

Answer selected by pedlima
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants