If using “Checkbox Value Contains”, it just compares if the value (string) is including a specific string.
For example, if you have the following Checkbox values:
blue-strawberry
red-strawberry
green-strawberry
white-apple
black-ananas
… and you enter “strawberry” in the Conditional Value, Pro Forms would autoselect blue-strawberry, red-strawberry and green-strawberry, because all three of them are containing “strawberry”.
This field should accept dynamic data. So you should be able to add {url_parameter:id} as well. Doing so, the checkbox value must be the Post ID. Or are you occuring problems here?
Conditionally checking the organisers related to an Event. I have a list of post IDs from a CPT called “organiser”. I also have a relationship field in a CPT called “events”. I created a form to update the events on the frontend. In the form, I created a checkbox field with a query loop showing all the organisers. I then want to conditionally check all organisers related to the current event.
The ACF Array only shows the option to define the ACF field name. It doesn’t specify from which post.
Oh okay. So it would help you to additionally have an additional control “Post ID” to be able to dynamically set a custom Post ID as context for the ACF data?
Now that I think about it, I guess this is more of a feature request. Instead of only having conditional checks for “if value contains,” we should also have conditional checks for “if values are in the list” or something similar, allowing us to define a list or array of values to check.
But isn’t that exactly what “If Value Is” does? When you loop the checkbox, this is queried individually for each checkbox and those to which it applies are marked.
If you enter “strawberry”, Pro Forms will look at each checkbox to see if there is a value that is “strawberry”. And if this is the case, it is marked with :checked.
Or am I misunderstanding you here? What would you like to enter for “If Value Is”? Is this an array itself that you want to compare with the given checkbox value? For example checking if the given checkbox value is included in the array you have inserted?
If value is… is checking for only one value, in this case strawberry. But I want to check for multiple values e.g. strawberry, blueberry, orange from a CPT containing multiple fruits.
A checkbox can have multiple selected values, not just one. And the options are coming for a query.
Ok, understood. So your value that you use to check is an array and Pro Forms should check if the given checkbox is included in the array. This would then select all three, strawberry, blueberry and orange in your case.
That’s simple. Let me add this later today. To test it out, I can send you the new build before deploying the official beta.2
After a community member’s question, I noticed that the select field has the option to Select if Option Value Contains Array Conditionally but doesn’t show any input. I’ve already set the select field to allow multiple selection