1

We have a form on a page, one of the feilds on the form is hidden and contains the following in the "Default incoming data" option field:

 {exp:member:custom_profile_data}
 {exp:channel:entries dynamic="no" channel="schools"}
   {if "{member_school}" == "{school_code}"}
     {title}
   {/if}
 {/exp:channel:entries}
 {/exp:member:custom_profile_data}

This code produces the correct results when pasted directly into the template, but when used with the freeform field it produces nothing.

Basically I'm checking that if the member_school field (From the member's profile) matches school_code (from the schools channel), then output the title of the schools article.

Any idea why this isn't working? Is custom profile data not supported by freeforms?

Thanks!

Here's the composer code we're using:

{exp:freeform:composer form_id="{embed:form_id}" return="{segment_1}/{segment_2}/thanks"}
<div class="ff_composer">
{composer:page}
    {composer:rows}
            <div class="line">
        {composer:columns}
                <div class="unit size1of{composer:column_total}">
            {composer:fields}
                {if composer:field_label}
                        <label {if composer:field_name != ''}
                            for="freeform_{composer:field_name}"
                            {/if}>
                            {composer:field_label}
                            {if composer:field_required}
                            <span class="required">*</span>
                            {/if}
                        </label>
                {/if}
                {if composer:field_output}
                    {if composer:field_type == 'nonfield_title'}
                        <h2>{composer:field_output}</h2>
                    {if:else}
                        {if composer:field_name AND composer:field_required}
                            {freeform:field:{composer:field_name} attr:required="required" attr:class="req"}
                        {if:else}
                            <p>{composer:field_output}
                            {if freeform:description:{composer:field_name}} 
                            <span class="instruction">{freeform:description:{composer:field_name}} </span>
                            {/if}
                            </p>
                        {/if}
                    {/if}
                {/if}
            {/composer:fields}
                </div>
        {/composer:columns}
            </div>
    {/composer:rows}
{/composer:page}
</div>
{/exp:freeform:composer}

After a bit more digging around:

Seems to output the member_school variable fine if I enter {exp:member:custom_profile_data}{member_school}{/exp:member:custom_profile_data} but it won't output the information from "schools" channel. If i just have {exp:channel:entries dynamic="no" channel="schools"}{title}{/exp:channel:entries} it outputs the current page's title instead of the school titles…

1

The "Default Incoming Data" option in the Freeform CP for hidden fields can accept tags and such, but complex template parsing, such as parsing of member fields and conditionals, could be a little too complex for this simple text input field, or not parsed in the correct order.

You could use a custom Composer Template with your Composer form, where you add a conditional for hidden field. When this conditional is met, try using your code to hard-code your own hidden field.

For example, starting with this section of your Composer Template code:

{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}
        <p>{composer:field_output}</p>
    {/if}
{/if}

Let's assume your hidden field name is "my_hidden_field". You could add a conditional for hidden fields like this:

{if composer:field_output}
    {if composer:field_type == 'nonfield_title'}
        <h2>{composer:field_output}</h2>
    {if:elseif composer:field_type == 'hidden'}
        <input type="text" name="my_hidden_field" value="
        {exp:member:custom_profile_data}
        {exp:channel:entries dynamic="no" channel="schools"}
          {if "{member_school}" == "{school_code}"}
            {title}
          {/if}
        {/exp:channel:entries}
        {/exp:member:custom_profile_data}
        " />
    {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}</p>
    {/if}
{/if}

You might also want to put your {exp:member:custom_profile_data}...{/exp:member:custom_profile_data} code on one line as well, or else your hidden field might also save extra spaces and linebreaks.

If trying this in the Composer Template editor in the CP doesn't work, try putting your Composer Template code in a regular EE template, inside a {exp:freeform:composer}...{/exp:freeform:composer} tag pair.

| 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.