XF 2.2 <xf:toggle> not working properly?

Newsman

Member
Hey y'all!

Whenever I use the <xf:toggle> tag in a template, I get the following error:

Unknown tag toggle encountered

Aside from adding a name, class and submit, am I missing something here?

Thanks for any help!
 
That tag is only valid within <xf:datarow>.

You can just add the iconic--toggle class to a checkbox label:

HTML:
<xf:checkboxrow>
    <xf:option name="some_option"
        label="Some label"
        labelclass="iconic--toggle" />
</xf:checkboxrow>
 
Alright, got that working - but I do not understand how I can tell my controller that the toggle has been switched.. do I need to wrap up the toggle and the submit button into a <xf:form> tag? What tutorials/templates can I look at for a simple example?
 
Yeah, the toggles are a checkbox input (just styled a little differently). They should belong to a form and otherwise behave as you would expected. This is the case even when using <xf:toggle> within a data row.

You can attach the click-submit handler if you want toggling the input to automatically submit the form, which is the case for <xf:toggle>:

HTML:
<xf:checkboxrow>
    <xf:option name="some_option"
        label="Some label"
        labelclass="iconic--toggle"
        data-xf-click="submit" />
</xf:checkboxrow>
 
Yeah, the toggles are a checkbox input (just styled a little differently). They should belong to a form and otherwise behave as you would expected. This is the case even when using <xf:toggle> within a data row.

You can attach the click-submit handler if you want toggling the input to automatically submit the form, which is the case for <xf:toggle>:

HTML:
<xf:checkboxrow>
    <xf:option name="some_option"
        label="Some label"
        labelclass="iconic--toggle"
        data-xf-click="submit" />
</xf:checkboxrow>

Thanks for the replies Jeremy - I was missing a form and once that was implemented, everything started to work as intended. Fantastic! :cool:
 
Top Bottom