Versions: EE 2.9.0 & Freeform 4.2.0 Pro

Some help would be appreciated. :-)

I am trying to implement inline error handling in a Freeform Composer Template and it is throwing 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 17.

The line of code that throws the error is this

{if freeform:error:{composer:field_name}}

Which is copied from your documentation

If I hard code in the field name like this:

{if freeform:error:first_name}

It works, I think. But I get an error for every field, even those not required.

Here is my complete Composer Template code

{composer:page}
{composer:rows}
        <div class="row">
            {composer:columns}
                <div class="columns {if composer:column_total == 2}six{if:elseif composer:column_total == 3}four{if:elseif composer:column_total == 4}three{if:else}twelve{/if}">
                    {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 freeform:error:{composer:field_name}}
                            <strong>
                                Error: {freeform:error:{composer:field_name}}
                            </strong>
                        {/if}
                        {if composer:field_type == 'nonfield_title'}
                            <h2>{composer:field_output}</h2>
                        {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}
                            {composer:field_output}
                        {/if}
                    {/if}
                {/composer:fields}
                    </div><!-- end columns -->
            {/composer:columns}
        </div><!-- end row -->
{/composer:rows}
{/composer:page}

Thank you.

up vote 3 down vote accepted

Change the lines

{if freeform:error:{composer:field_name}}
                        <strong>
                            Error: {freeform:error:{composer:field_name}}
                        </strong>{/if}

TO

{if "{freeform:error:{composer:field_name}}" != ""} 
                        <strong>
                            Error: {freeform:error:{composer:field_name}}
                        </strong>{/if}

in the Template code. That should work.

  • Thank you. I just spent 60 minutes and the inline form error processing is happening. I tried using the composer and freeform tags. Nothing. Something is up. – hfrancke Oct 15 '14 at 19:38
  • Today I revisited the issue and managed to get things working. I am not sure exactly what I did, but your code did help! – hfrancke Nov 5 '14 at 0:31

Here is the code that is working for us, based on enj fix. Thank you!

{composer:rows}
        <div class="row">
            {composer:columns}
                <div class="columns {if composer:column_total == 2}six{if:elseif composer:column_total == 3}four{if:elseif composer:column_total == 4}three{if:else}twelve{/if}">
                    {if composer:field_total == 0}

                    {/if}
                {composer:fields}
                    {if "{freeform:error:{composer:field_name}}" != ""}<span class="error">{/if}
                    {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_captcha'}
                            {if freeform:captcha}
                                    {freeform:captcha}<br />
                                    <input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
                            {/if}
                        {if:else}
                            {composer:field_output}
                        {/if}
                    {/if}
                    {if "{freeform:error:{composer:field_name}}" != ""}</span>{/if}
                {/composer:fields}
                    </div><!-- end columns -->
            {/composer:columns}
        </div><!-- end row -->
{/composer:rows}

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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