1

I would like to show inline errors on my composer form in Freeform. I tried the template code mentioned at https://expressionengine.stackexchange.com/a/25346/961 which is:

<p>
    {composer:field_output}

    {!-- composer:field_name will parse first to the field's name --}
    {if freeform:error:{composer:field_name}} 
        <strong>{freeform:error:{composer:field_name}}</strong>
    {/if}
</p>

but it's giving me the error:

You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Parser State: Unexpected ‘:’ (MISC); expected RD in on line 28.

If I remove the inline error code then it works ok but obviously doesn't show the inline errors.

The full composer template is as follows:

<div class="ff_composer">
{composer:page}
    {composer:rows}
            <div class="line">
        {composer:columns}
                <div class="unit size1of{composer:column_total}">
                {if composer:field_total == 0}
                     
                {/if}
            {composer:fields}
                {if composer:field_label}
                    {if composer:field_type == 'nonfield_captcha'}
                        {if freeform:captcha}
                        <p>
                            <strong>{composer:field_label}</strong>
                        </p>
                        {/if}
                    {if:else}
                        <label class="field_label" {if composer:field_name != ''}for="freeform_{composer:field_name}"{/if}>
                            {composer:field_label}{if composer:field_required}<span class="required_item">*</span>{/if}
                        </label>
                    {/if}
                {/if}
                {if composer:field_output}
                    {if composer:field_type == 'nonfield_title'}
                        <h2>{composer:field_output}</h2>
                    {if:elseif composer:field_type == 'nonfield_paragraph'}
                        {composer:field_output}
                    {if:elseif composer:field_type == 'nonfield_captcha'}
                        {if freeform:captcha}
                                {freeform:captcha}<br />
                                <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
                        {/if}
                    {if:else}
                        <p>
                        {composer:field_output}
                            {!-- composer:field_name will parse first to the field's name --}
                            {if freeform:error:{composer:field_name}} 
                                <strong>{freeform:error:{composer:field_name}}</strong>
                            {/if}
                        </p>
                    {/if}
                {/if}
            {/composer:fields}
                </div>
        {/composer:columns}
            </div>
    {/composer:rows}
{/composer:page}
</div>
2
  • As per document this must be placed within the composer:fields variable pair like : {composer:fields} {/composer:fields}
    – Jainil
    Jan 16, 2017 at 13:13
  • @JainilNagar It is within that variable pair. I've updated the question to show the full template code.
    – Patrick64
    Jan 16, 2017 at 13:23

1 Answer 1

2

For EE3, it appears that Freeform 5.x is a bit fussier about the conditional. Try this code instead:

<p>
    {composer:field_output}

    {!-- composer:field_name will parse first to the field's name --}
    {if "{freeform:error:{composer:field_name}}"}
        <strong>{freeform:error:{composer:field_name}}</strong>
    {/if}
</p>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.