XF 2.1 Conditional statement in xf:option tag?

NicolasZN

Well-known member
An add-on I'm working on has the following lines in it:
Code:
                <div class="block-body">
                    <xf:radiorow name="username">
               
                        <xf:foreach loop="$subAccounts" value="$user">
                            <xf:option value="{$user.username}" selected="{{ $username == $user.username }}">
                                {$user.username}
                                <xf:if is="{$user.conversations_unread}">
                                    <i class="far fa-envelope"></i>
                                    <span class="badgeContainer{{ $user.conversations_unread ? ' badgeContainer--highlighted' : '' }}"
                                    data-badge="{{ $user.conversations_unread ? $user.conversations_unread|number : 0 }}" title="{{ phrase('conversations') }}">
                                    </span>
                                </xf:if>
                                <xf:if is="{$user.alerts_unread}" />
                                    <i class="far fa-bell"></i>
                                    <span class="badgeContainer{{ $user.alerts_unread ? ' badgeContainer--highlighted' : '' }}"
                                    data-badge="{{ $user.alerts_unread ? $user.alerts_unread|number : 0 }}" title="{{ phrase('alerts') }}">
                                    </span>
                                </xf:if>
                            </xf:option>
                        </xf:foreach>
                   
                    </xf:radiorow>
                </div>
The xf:if statement I just added to try to hide the font awesome icons if there aren't unread alerts/conversations.
However, as a result, whenever I try to rebuild the add-on I'm receiving:
Code:
Option tag contains an unexpected child element. - Template name: public:template_name_here
I know it's the xf:if statement, but am wondering if there's any way I can achieve what I'm trying to achieve with an acceptable child element?
 
Any guidance at all would be appreciated.
I can't find any documentation on the xenforo syntax and the option tag, let alone any which suggests conditional statements are disallowed within an option tag.
Is there something else incorrect in the code posted above?
 
Top Bottom