Skip Navigation

[Resolved] Output checkbox values as list

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
- 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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 6 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1116322

Hi Toolset,

I'm using a user field with checkboxes and i would like to output the values as a unordered list instead of comma separated list. Any idea how to solve this? Thanks!

- Menno

#1117063

Hi Menno,

Thank you for contacting us and I'll be happy to assist.

To show your checkboxes values in an unordered list, you can add them as:


<ul>
<li>[types field='topics-covered' separator='</li><li> '][/types]
</li>
</ul>

To add different labels or for more control over the markup, you can also use “Fields and Views” button in your content template.

When you'll click it to insert the field, you’ll see the option “Custom values for selected and not selected states”.

Please select it and wrap your selected values, inside


<li></li>

and leave the unselected ones empty.
( screenshot: hidden link )

After inserting the field, you can wrap all the fields inside a


<ul> </ul>

e.g.


<ul>
[types field='topics-covered' state="checked" option="0"]<li>Sports</li>[/types]
[types field='topics-covered' state="checked" option="1"]<li>Community</li>[/types]
[types field='topics-covered' state="checked" option="2"]<li>Politics</li>[/types]
</ul>

I hope this helps! Please let us know if you need any further assistance.

Regards,
Waqar

#1117130

Thanks Waqar! I had to get rid of the comma and have each value on a new line, so i used this code to remove it and replace it with a break:

<?php echo types_render_usermeta( 'opening-hours', array( "user_id" => $curauth->ID, "separator" => "<br>") ); ?>
#1117179

Hi Menno,

Thanks for the update and glad you managed to sort it out on your own.

Please let us know if you have further questions and for the fastest assistance with a new question, please open a new ticket.

Have a great weekend!