Hi,
I am searching for the correct conditional statement for checking whether a checkbox is checked as part of a multi-checkbox. (I don't care if there are many options checked, only that this specific option MUST be checked in order to display the text I want)
I tried this:
[wpv-conditional if="( '[types field='conference-categories' option='9'][/types]' eq '10' )"]
TEST STRING
[/wpv-conditional]
from this thread: https://toolset.com/forums/topic/conditional-display-depending-on-checkbox-2/
and also this:
{!{wpv-conditional if="( '[types field='schutzart-ip' option='0'][/types]' eq 'ip66' ) AND ( '[types field='schutzart-ip' option='1'][/types]' eq 'ip67' )" debug="true"}!}
TEST
{!{/wpv-conditional}!}
from this thread: https://toolset.com/forums/topic/conditional-output-based-on-multiple-checkboxes/#post-1225586
But neither of them worked for me. See my screenshot, I swapped out the field value above for "contact-role", left in option= "0" because it is the first in the list of checkbox options, and made it to eq "Rabbi".
Can you let me know if there's something I'm missing?
Thanks!
Hello,
I suggest you try the types shortcode with attributes "option" + "unchecked", like this:
[types field="my-checkboxes" option="0" state="unchecked"]First option checked[/types]
[types field="my-checkboxes" option="1" state="unchecked"]Second option checked[/types]
More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes
Thanks for the quick response,
so for me it would look like this:
[types field="contact-role" option="0" state="checked"][types field="first-name"] [/types][types field="last-name"][/types]
The shortcode works in that it displays the first and last name for the option "0" that is checked, but it also doesn't work. It also displays only the last name of every related post, which is super strange.
To elaborate so you understand exactly what is going on, this shortcode is being put inside a content template (legacy, not block editor) loop-view, which is being nested inside another (parent) loop-view. The parent loop of each post is the location, and this nested loop is supposed to show the first and last name of people that are connected to the location, (the query filter I set up for it is: Locations to People relationship that are a related to the current post in the loop.) - But I want only the people with this specific option checked (option "0") to display- it is a one to many relationship where many people can be connected to one location. So for some reason this shortcode is adding in everyone that is connected to the location, displaying the first and last name for option 0, and only displaying the last name for the rest of the related people in the location.
Any idea how this can be happening?
You are using wrong codes, please try to modify it as below:
[types field="contact-role" option="0" state="checked"]
[types field="first-name"] [/types][types field="last-name"][/types]
[/types]
And test again
Now it is showing up with the word [/types] at the end of each name that is being displayed.
ie: "Doe [/types] Smith [/types]" etc.
Please try these shortcode, and test again:
[types field="contact-role" option="0" state="checked"]
[types field="first-name"] [types field="last-name"]
[/types]
Thanks Luo!
My issue is resolved now. Thank you!