Fixed Inconsistency with some template elements

Siropu

Well-known member
Affected version
2.2.7
Adding class attribute to <xf:checkbox> doesn't work but adding a data attribute works.
Adding data attribute to <xf:optgroup> inside a <xf:checkbox> doesn't work but adding a class attribute works.
 

Chris D

XenForo developer
Staff member
I feel like this is broadly correct.

You have to bear in mind that template tags, often attempt to simplify what is multiple elements into something much simpler. Bear in mind <xf:checkbox> actually includes a bunch of wrappers, the label, the checkbox(es), a wrapper for the icon etc. So occasionally there are distinct ways to give something a class rather than a simple class attribute, or sometimes a class attribute might not work at all because it doesn't make sense.

In terms of:

Code:
<xf:checkbox class="some-class">
    <xf:option label="I am a checkbox" name="1" />
</xf:checkbox>

Where are you expecting/wanting some-class to be added? The list wrapper element? The checkboxes themselves? The label? It's ambiguous. If you want to add a class to the outer list element you can use the listclass attribute.

There are other ways to add classes to those other things I mentioned. You can add class to the <xf:option> tag which will give the checkbox element itself a class. Or you can add labelclass if you want the label to have a specific class.

As for the data attributes not showing on the input group, I think we can add support for that, at least.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.8).

Change log:
Support adding data attributes to <xf:optgroup> elements inside xf:checkbox and xf:radio elements.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top