XF 2.1 Displaying only checked boxes in custom field checkbox

Goodnightpanda

Active member
Can't find anything on how to display the selected options from a custom field using checkboxes. Anyone know how to write the conditionals?

idea: Trying to make checkboxes for the 7 days of the week and if a user checks the box for monday and friday, I want it to display the Text of those 2 options only.
 
Solution
That is in the templates - you use that code to extract the custom field values, something like this:

HTML:
<xf:foreach loop="$xf.visitor.Profile.custom_fields.day" value="$day">
    {$day}
</xf:foreach>

That will print out the value of all checked items.


Or you can use the join filter:

HTML:
{$xf.visitor.Profile.custom_fields.day|join}
The custom fields array would take this form - $xf.visitor.Profile.custom_fields.day where day is the field ID.

If you choice values are the names of the days of the week like this ...

1607624713116.png

... then dumping that would give this if Tuesday and Thursday are checked.

1607625322781.webp
 
That is in the templates - you use that code to extract the custom field values, something like this:

HTML:
<xf:foreach loop="$xf.visitor.Profile.custom_fields.day" value="$day">
    {$day}
</xf:foreach>

That will print out the value of all checked items.


Or you can use the join filter:

HTML:
{$xf.visitor.Profile.custom_fields.day|join}
 
Solution
Top Bottom