XF 2.0 Content check inside a Form throwing an error

abdfahim

Well-known member
Why can't I use contentcheck inside a form?

Error:
Line 89: Tag must be a valid conditional using an is attribute or content checking. (Line 89 is the last line)

My Code:
Code:
<xf:if contentcheck="true">
    <xf:form action="{{ link('account/custom-save') }}" ajax="true">
        <xf:contentcheck>
            <xf:if is = "!{$user.Profile.custom_fields.customA}">
                <input class="input" type="text" id="customA" name="customA">
            <xf:elseif is = "!{$user.Profile.custom_fields.customB}" />
                <input class="input" type="text" id="customB" name="customB">
            <xf:elseif is = "!{$user.Profile.custom_fields.customC}" />
                <input class="input" type="text" id="customC" name="customC">
            </xf:if>
        </xf:contentcheck>
        <xf:button type="submit" class="button--primary">{{ phrase('update') }}</xf:button>
    </xf:form>
</xf:if>

If I remove contentcheck blocks, or the xf:form block, it works fine.
 
Anybody can comment on the above post, please? Is it by design, or I am missing something, or a bug?

Here is a snapshot with a very simple code block

Capture.webp
 
It's expected. Content checking can't have any XF template syntax tags between the if and the contentcheck. This is specifically for adding extra basic HTML.

There are a couple potential resolutions though you need to be aware of some of the specifics. You may be able to use <xf:set /> to set the content if needed (though that you have to be careful about how you write the condition) or you could do something like post_macro's $hasActionBarMenu approach.
 
It's expected. Content checking can't have any XF template syntax tags between the if and the contentcheck. This is specifically for adding extra basic HTML.

There are a couple potential resolutions though you need to be aware of some of the specifics. You may be able to use <xf:set /> to set the content if needed (though that you have to be careful about how you write the condition) or you could do something like post_macro's $hasActionBarMenu approach.
Hello.
I'm stucked in the same error.

I want ot replace some block of code in "login" Template
XML:
<xf:if contentcheck="true">
  <div class="blockMessage blockMessage--error blockMessage--iconic">
    <xf:contentcheck>{$error}</xf:contentcheck>
  </div>
</xf:if>

With this:
XML:
<xf:if contentcheck="true">
    <xf:if is="$error != 'login_required'">
        <div class="blockMessage blockMessage--error blockMessage--iconic">
            <xf:contentcheck>{$error}</xf:contentcheck>
          </div>
    </xf:if>
</xf:if>

Because I don't want to see a stupid error phrase "You must be logged-in to do that".
But I want to see other error messages like invalid password or do.

Please suggest any workaround.
 
Back
Top Bottom