I have a site using Toolset and I have several custom fields of type checkboxes, with the option "When unchecked, save 0 to the database" set.
I also use content templates to view the posts in the front end, displaying these fields.
In the content template I'm insetting the Types custom fields and for these checkboxes on the display options I'm using "Custom values for selected and not selected states" resulting in something like the following:
[types field='<name-of-field>' state="checked"]<span class="a35-symbol-checkbox-checked"></span>[/types][types field='<name-of-field>' state="unchecked"]<span class="a35-symbol-checkbox"></span>[/types]
I would expect that the custom values depending on the checkbox value be displayed. This is not happening/working with the last Types version 3.1.2.
Any advice on this would be appreciated. Thanks
Hi, first I would like to point out that saving 0 to the database is known to cause problems with custom searches. If possible, it's best to avoid using this setting. It's advised to update your content as explained here: https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/
If it's not possible to update your content, we have a patch available for the checked / unchecked display issue here:
https://toolset.com/errata/checkbox-and-checkboxes-fields-saving-0-will-display-checked-custom-value-even-if-not-checked/
You may need to recreate your types field shortcodes using the Fields and Views button, because they don't seem to include the option numbers for each possible checkbox. The correct format looks like this:
[types field='name-of-field' state="checked" option="0"]checked[/types]
[types field='name-of-field' state="unchecked" option="0"]unchecked[/types]<br />
[types field='name-of-field' state="checked" option="1"]checked[/types]
[types field='name-of-field' state="unchecked" option="1"]unchecked[/types]<br />
[types field='name-of-field' state="checked" option="2"]checked[/types]
[types field='name-of-field' state="unchecked" option="2"]unchecked[/types]<br />
Hi, thanks for the solution.
First, I'd like to apologize because I referred a custom field of type "checkboxes" and presented a shortcode example of a custom field of type "checkbox" (single).
Actually I have both types of custom fields, and the problem is comum.
The solution of updating the custom fields settings and then the content would be a problem.
I already have dozens of customs fields in dozens of forms with hundreds of posts in the client production site.
So, the solution presented by the errata is welcome.
It worked perfectly.
Thanks again.
Okay great, thanks for the update.
My issue is resolved now. Thank you!