• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

<xen:checkboxunit>, <xen:options> and checked...

Liam W

Well-known member
#1
I have this in an admin template:

HTML:
<xen:checkboxunit label="{xen:phrase liam_walc_prod_add_ug}:" name="usergroups">
        <xen:options source="$usergroups" checked="$product.usergroups" />
        <xen:explain>{xen:phrase liam_walc_prod_add_ug_exp}</xen:explain>
</xen:checkboxunit>
$products.usergroups is an array, like so (using the dump template helper):

Code:
array(2) {
  [0] => string(1) "3"
  [1] => string(1) "1"
}
The checkboxes show fine, but none of them are selected, even with the array above.

Any idea as to why? It's got me stumped...

Liam
 

Liam W

Well-known member
#2
Ok, this really is starting to annoy me now, it's happening with a different set of data as well...

What am I doing wrong?!?!?

Liam
 

Liam W

Well-known member
#3
Ok, figured it out...

The source array should contain a checked key, to tell if it should be checked or not.

The checked entry does nothing...

Liam
 

Liam W

Well-known member
#5
Im using the checkbox option, and having trouble getting the boxes check as well, what should the array look like.
http://stackoverflow.com/questions/...heckboxes-to-repopulate-using-xenforo-options
Thanks
Liam W said:
The _render method in the XenForo_Option_NodeChooser class expects there to be only one selected node, so it expects the value to be a single unsigned integer node_id.

As you're passing it an array, it doesn't work.

You would have to create your own standalone method to add in this option.