(Fixed) default_value is not a valid array

Satis

New member
Hi there.

I'm trying to make an option section with 2 checkboxes.
The first checkbox is the main one and the second one is an child of the first one.

I'm using:
  • Edit Format: Named Template
  • Format Parameters: option_template_MC_RTR
  • Data Type: Array
  • Default Value: a:2:{b:0;b:0;}
  • Array Sub-Options: adminNeedTested, noAdminSelfTesting
Image of the setup:
MC_002.webp

The admin template "option_template_MC_RTR" looks like this:
HTML:
<xen:checkboxunit label="">
    <xen:option name="{$fieldPrefix}[{$preparedOption.option_id}][adminNeedTested]" label="{$preparedOption.title}" value="1"
        selected="{$preparedOption.option_value.adminNeedTested}">
        <xen:hint>{xen:phrase stopforumspam_enable_registration_check_explain}</xen:hint>
        <xen:checkbox>
            <xen:option name="noAdminSelfTesting" selected="{$preparedOption.option_value.noAdminSelfTesting}">
                <xen:label>Test Label<!--{xen:phrase stopforumspam_moderate_registration_threshold}-->:</xen:label>
            </xen:option>
        </xen:checkbox>
    </xen:option>
    <xen:explain>{xen:raw $preparedOption.explain}</xen:explain>
</xen:checkboxunit>

Once I click Save Option, I get this error:
MC_003.webp

Now I have been searching and reading a little here on XenForo forum, help page and the resource section, to try to figure out how the array default options needs to be done, and the only thing I found on this issue is this threat about it: Default value for data type array

But there is not much of help on it, since after what I can see on that page and on other options sections, the default value looks alright, but I'm still very new to making addon's for XenForo and I'm clearly missing something important.

So anyone that could point me in the right direction or explain how this would need to be setup in more dept, would be appreciated allot.

Kind regards
Satis
 
the default value looks alright
Unfortunately, it's not. Pop the value through unserialize and you'll see you get an error: "unserialize(): Error at offset 9 of 14 bytes".

Have a look at another option that is formatted like you want and see how it's implemented and the structure of the default value. It should point you to what you need to use.
 
Aha!
Thanks for pointing me in the right direction.
I did a quick search on google to learn a bit more about the unserialize :)

I have to do it this way instead :P
Code:
a:2:{s:15:"adminNeedTested";b:0;s:18:"noAdminSelfTesting";b:0;}

I actually tried that at one point but it didn't work, but that was due to me not adding the quotes around the string value. (Silly me) it was looking like this :P
Code:
a:2:{s:15:adminNeedTested;b:0;s:18:noAdminSelfTesting;b:0;}

Anyway, I got it to work and thanks again. You are an champ ;)
 
Top Bottom