Hi there,
I have a form with multiple checkboxes and selects. I need to trigger validation of select when value of checkbox change, but not sure how to achieve this.
Here is my code:
<Form onSubmit={onSubmit}>
{({formProps}) => (
<form {...formProps}>
<FormSection>
<Grid spacing="compact" columns={GRID_COLUMNS}>
{sentinelVulnerabilities.map((vulnerability: { label: string, value: string }) => {
return (
<Fragment>
<GridColumn medium={4}>
<Checkbox
name={vulnerability.value}
label={vulnerability.label}
onChange={onChange}
title={vulnerability.label}
isChecked={isChecked[vulnerability.value]}
value={vulnerability.value}
/>
</GridColumn>
<GridColumn medium={8}>
<Field<Value<Option>>
name={vulnerability.value}
defaultValue={getDefaultValue(vulnerability.value)}
validate={(value: any) => validate(value, vulnerability.value)}
>
{({fieldProps: {id, ...rest}, error}) => (
<Fragment>
<Select
inputId={id}
{...rest}
options={jiraIssuePrioritiesOptions}
placeholder={"Select Jira Issue priority"}
isClearable
/>
{error && <ErrorMessage>Can not be empty </ErrorMessage>}
</Fragment>
)}
</Field>
</GridColumn>
</Fragment>
)
})}
</Grid>
</FormSection>
<FormFooter>
<LoadingButton isLoading={isSubmitting} type="submit" appearance="primary">
Save Mapping
</LoadingButton>
</FormFooter>
</form>
)}
</Form>
As you can see, checkbox is not a and I do not need these values in submitted data.
Is there a simple solution how to trigger validation of select when checkbox is clicked?
Thank you