Schema.model({
field1: StringType(),
field2: StringType(),
field3: StringType()
})
return (
<Form
model={model}
>
<FormControl name="field1" />
<FormControl name="field2" />
<FormControl name="field3" />
</Form>
)
How to set the field2
and field3
to required field?
What I'm trying to do is when field
is equal to jake
the field2
and field3
will be required. but when its not equal to jake
then its not required.
I tried to use the onChange
on the field1
but it doesn't work.
also I tried the addRule
in field2
& field3
but it doesn't work also.
addRule((value, data) => {
if (data.field1 ==='jake') {
return true;
} return false;
}
I want to apply this in field2 and field3 StringType().isRequired('Required field')
when the value in field1 is jake.