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

Select Template Error

Discussion in 'XenForo Development Discussions' started by Morgan, Apr 2, 2012.

  1. Morgan

    Morgan 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='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/mlp/domains/massivelan.com/public_html/forum2/library/XenForo/Template/Abstract.php(265) : 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="{$_criteriaUg.id}" selected="in_array({$_criteriaUg.id}, {$userCriteria.steam_not_game.games})">{$_criteriaUg.name}</xen:option>
    I'm pretty sure that I'm missing something important but really I have no idea what! I'm expecting the array $userCriteria.steam_not_game.games to be null at this point since it hasn't be initialized given this is a new notice!

    Thanks for any help :D
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Try this:

    selected="{$userCriteria.steam_not_game.games} AND in_array({$_criteriaUg.id}, {$userCriteria.steam_not_game.games})"
    Morgan likes this.
  3. Morgan

    Morgan Active Member

    Thanks! That worked and makes sense!

Share This Page