Skip Navigation

[Resolved] Display only checked choices in checkbox fields on different lines

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.

This topic contains 3 replies, has 2 voices.

Last updated by trishaT 1 year, 2 months ago.

Assigned support staff: Jamal.

Author
Posts
#2030951
Problem 2 - each choice on a different line.png

Tell us what you are trying to do? A field has a checkbox question with several possible choices. I would like to display their choices in two ways: First - only the choices they make (not all choices), and second - I want them to display on different lines, like:
A. This choice
C. This choice
G. This choice

I suspect I need to use

  • etc somewhere but I don't know where.

    Is there any documentation that you are following? I can't find any. I have done many searches.

    Is there a similar example that we can see? When I watch the video tutorials, the choices are listed linearly - I need them to be listed vertically.

    What is the link to your site? You can see this here: hidden link In the uploaded image, you'll see pink bullet points next to each one that should be found on each line.

#2031655

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

To display each option in a line, you can use this, adapt it to your field's slug:

<p>
    [types field="my-checkboxes" separator="
"][/types]
</p>

Which will generate:

<p>
Option 1 

Option 2 <br>
Option 3
</p>

You said that you want to display only the options that are selected, this is the default behavior. Are you getting some options that are not selected? If yes, please check what settings have you chosen for the field in Toolset->Custom fields. And make sure that the field will save "nothing" when an option is not selected instead of "0". Then save a post again to force it to remove 0s for the unchecked options and try again.

I hope this helps. Let me know if you have any questions.

#2031657

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

The code has been changed because of how the forum works. Please check the raw reply on this pastebin https://pastebin.com/SFNQx08q

#2031711

Jamal - thanks for this. In the process of trying to add your code, I figured out that I can add the "<br>" during the set up of the shortcode, so that's how I've made it work.

So - you helped me, and I learned something! I appreciate it.