Condition based on an array field 'includes' #1313
-
Hi! Our form has a field that holds an array of strings, and we'd like to conditionally hide/show other fields based on whether or not that array contains a given value. Curious how we might achieve that? An example use-case below.
We only want the input for Ideally, we have something like:
Such that when Let me know if that makes sense and is supported - we can take a look at adding this functionality in a PR if it's not and seems useful to others. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
hi @logancameo the condition definition allows using a function for the If you send me a sample schema I can tinker around with it and prepare an example. {
when: (field) => `${getFieldNumber(field)}.name`
}
/*
field = {
name: 'person[14]',
}
*/ It's possible that your use case may require a custom component wrapper. In that case, a component wrapped in a FormSpy or with additional |
Beta Was this translation helpful? Give feedback.
-
Hello, there is no schema based attribute to support that, but you can achieve the same result using custom is function. condition: {
when: 'Foo',
is: (value) => value?.includes('foo')
} |
Beta Was this translation helpful? Give feedback.
@logancameo
Hello,
there is no schema based attribute to support that, but you can achieve the same result using custom is function.
Read more here