Skip to content

Is there a way to update defaultValue using an onChange handler? #526

Closed Answered by edmundhung
JPMagtang asked this question in Q&A
Discussion options

You must be logged in to vote

You can decide whether the select all checkbox should be checked based the value of the form / fields through form.value / fields.permissions.value etc. To update multiple checkbox at once, you can consider using form.update() at the permissions level instead of individual checkbox, e.g.

// This makes sure conform subscribe to the permission value
// So you won't have an outdated value inside toggleSelectAll (More info on #467)
const permissions = fields.permission.value;

function toggleSelectAll() {
  form.update({
    name: fields.permissions.name,
    value: {
      ...permissions,
      // ... all the changes you wanna made
    },
  });
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JPMagtang
Comment options

@edmundhung
Comment options

Answer selected by JPMagtang
@JPMagtang
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants