Skip Navigation

[Resolved] Output of the checkboxes custom field prints comas even where an empty field

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

Problem:
Outputting a Types checkboxes fields prints commas where options are unchecked.

Solution:
This was a bug fixed in Types 3.0.3

This support ticket is created 6 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Mykola Yabchenko 6 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1106358
Знімок екрана 2018-09-12 08.24.14.png
Знімок екрана 2018-09-12 08.23.41.png

Tell us what you are trying to do?
I am setting up organizations section on my website. Each organization can operate in several countries so I have added checkboxes custom field. Setup is like this- When unchecked, don't save anything to the database, when checked - save 1. I have checked first country (Italy) in the list and when I open a page I see - 1, , ,. So it outputs 1 instead of Italy and then empty spaces separated by comas.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
nixx.pp.ua

#1106468

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-09-12 at 08.39.13.png

Hi Mykola

I don't see any debug info for your site so I'm not sure which versions you have installed, but the issue about the commas being output for the unchecked options was fixed in Types 3.0.3, so make sure your plugin is up-to-date and you shouldn't see that.

Regarding seeing the 1s rather than the country names, that is expected: https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

"With no attributes set, checkboxes will return a comma separated list of values stored for each checked checkbox."

If you want to output the country name, either save the country name to the database (instead of 1), or choose an alternate value to display (see example in screenshot).

#1106784

Thanks! That was it