Select Template Error


Active member
So I'm a bit confused on what I'm doing wrong so instead of beating myself up and giving up just to ask I figured that someone here might be able to point out what I've been missing! I am making custom notice fields for a user and as such adding a multiple selection. This works fine when the user criteria is selected and such, but when it isn't (such as a new notice or one that doesn't use this data) I get the following error:
in_array() [<a href=''></a>]: Wrong datatype for second argument in /home/mlp/domains/ : eval()'d code, line 55:
54: 'value' => htmlspecialchars($_criteriaUg['id']),
55: 'selected' => (in_array($_criteriaUg['id'], $userCriteria['steam_not_game']['games'])),
56: 'label' => htmlspecialchars($_criteriaUg['name'])
The relevant section of my template is:
<label><input type="checkbox" name="user_criteria[steam_not_game][rule]" value="steam_not_game" class="Disabler" id="ucrit_steam_not_game" {xen:checked $userCriteria.steam_not_game} />{xen:phrase steam_game_not_owned}:</label>
<div class="criteriaQualifier" id="ucrit_steam_not_game_Disabler">
    <xen:select name="user_criteria[steam_not_game][data][games]" size="8" multiple="true">
        <xen:foreach loop="$steam_games" value="$_criteriaUg">
            <xen:option value="{$}" selected="in_array({$}, {$})">{$}</xen:option>
I'm pretty sure that I'm missing something important but really I have no idea what! I'm expecting the array $ to be null at this point since it hasn't be initialized given this is a new notice!

Thanks for any help :D

Jake Bunce

XenForo moderator
Staff member
Try this:

selected="{$} AND in_array({$}, {$})"