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>
  • As per document this must be placed within the composer:fields variable pair like : {composer:fields} {/composer:fields} – Jainil Jan 16 '17 at 13:13
  • @JainilNagar It is within that variable pair. I've updated the question to show the full template code. – Patrick64 Jan 16 '17 at 13:23
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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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