Skip Navigation

[Resolved] Checkboxes conditional not working properly

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to show icons for each checkboxes field that is checked for a specific post. The checkbox conditionals I have placed in my template don't seem to be working as expected.

Solution: Be sure you have NOT selected "save 0 when unchecked" for this checkboxes group field. Then resave any posts with these checkboxes fields to update those values. In the field conditionals, don't use the "wpcf-" prefix with the field slugs.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by ivanJ 6 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1145844

Hey guys,

I've recorded a video for you to check out my issue, can you please check it out and see the whole problem.

Link:

Best,
Ivan

#1145848

Hello,

Sorry, here's the link: hidden link

Best,
Ivan

#1145978

Hi, the main thing I see here is the checkboxes field is set to "save 0 to the database" when unchecked. This setting is often problematic, and my best advice here is to save nothing when unchecked. Then resave the post to update the saved checkboxes values, and test your conditionals again. If this doesn't resolve the problem, I'll be glad to take a closer look.

#1146542

Hello Christian,

That didn't resolve the issue. Please enter the site, the backup has been made.
Thanks

Best,
Ivan

#1146628

Okay it looks like the slug of the field included the "wpcf-" prefix, but it's not necessary here. The slug "room-specification" is sufficient:

         [types field="room-specification" option="0" state="checked"]
            <div class="single--icon tv--icon">
                <img src="/wp-content/uploads/2018/04/tv.svg" class="style-svg" alt="room icon" />
                <h4>Television</h4>
            </div>
        [/types]

I made that change for all the option fields in your BB Themer Layout. Then I resaved this post in wp-admin to save the correct checkbox values: hidden link

Looks like the correct icons are displaying now. Can you confirm? You must re-save all the single Room posts to update the checkboxes and display the correct icons.

#1146634

My issue is resolved now. Thank you!