Skip Navigation

[Resolved] Checkbox / Conditional Logic Stopped Working?

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

Problem:

I've set up some checkboxes fields and then use the following code to bring them into the front end:

[types field='week-1' option='0' state='checked'] YES [/types]

[types field='week-1' option='0' state='unchecked'] NO [/types]

This was working absolutely fine (see screenshot 01 with the title 'pre commencement'), and seems to be a pretty standard option for Toolset. However, since I've run the updates on all of the Toolset plugins, it's stopped working...

Solution:

it is a known issue:

There is an issue with the Checkbox fields that save “0” when they are not set on a post.

You will need to change all checkboxes field setting to "When unchecked, don't save anything to the database", and resave all posts, and test again.

Relevant Documentation:

https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

This support ticket is created 6 years, 3 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by williamJ-2 6 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1132706
Screen Shot 2018-10-23 at 14.31.59.png
Screen Shot 2018-10-23 at 14.30.43.png

Hi,

I've set up some checkbox lists and then use the following code to bring them into the front end:

[types field='week-1' option='0' state='checked'] YES [/types]

[types field='week-1' option='0' state='unchecked'] NO [/types]

This was working absolutely fine (see screenshot 01 with the title 'pre commencement'), and seems to be a pretty standard option for Toolset. However, since I've run the updates on all of the Toolset plugins, it's stopped working...

If one field in the checklist has been ticked, they all automatically bring in the 'Yes' option, rather than a mixture of Yes & No.

Any ideas why this is happening?

Thanks.

#1133232

Hi,

I have tried your codes in my localhost in a fresh wordpress installation, it works fine.

So the problem is abnormal, please try these:

1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

2) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL, I need to test and debug it in my localhost, thanks

https://toolset.com/faq/provide-supporters-copy-site/

#1134056
checkboxes.JPG

Thanks for the details, I can duplicate the problem, they are checkboxes fields, and it is a known issue:
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

There is an issue with the Checkbox fields that save “0” when they are not set on a post.

I have tried it with your database dump file in my localhost, please try these:
1) Edit post field group "Task List - Pre-Commencement", edit checkboxes field "Pre-Commencement", switch to option:
When unchecked, don't save anything to the database
2) Edit the "Job" post "Editor's First Project", save it again
3) Test it in front-end, it works fine, see screenshot checkboxes.JPG

So you will need to change all checkboxes field setting to "When unchecked, don't save anything to the database", and resave all posts, and test again.

#1134146

Hey Luo,

Perfect - I did look through the known errors and couldn't find this error.

Thank you for your help, It's working now!

Best wishes,

Jake.