I couldn't see it in the docs - is there a way to do inline error handling with a Freeform Composer form when you've selected the form in a fieldtype? I want the authors to be able to add a form of their choice to a page by selecting the form in the dropdown, but also have the error handling done inline.

The docs simply suggest using the field's short name which outputs the form, but the errors go to the ugly error screen and the info added is lost when you go back.

I can see there's a {exp:freeform:composer} tag, but I'm not sure how to grab the relevant form ID from the selected option in the fieldtype?

Cheers

  • The form ID is displayed next to your form under the "Forms" section in the Freeform module, in the CP. You then use it with {exp:freeform:composer} like this: {exp:freeform:composer form_id="YOUR ID HERE"} – Solspace Aug 27 '14 at 9:16
  • I understand that, but what I'm after is being able to select the form to output on the page by using the fieldtype dropdown, and also have inline error handling. So I could have something like : [code]{exp:channel:entries channel="pages" dynamic="yes"}{exp:freeform:composer form_id="{form_field_short_name:id_of_form}" composer_template_name="general_form" return="expressions-of-interest-2015/thank_you" } [/code] - does that make it any clearer? Finding it hard to explain! – Tim Jukes Aug 27 '14 at 12:35
  • Unless you find a way to store form_ids in a custom field, this is not how Composer forms can be displayed from a {exp:channel:entries} tag pair. Freeform Pro comes with a Freeform fieldtype that lets you select a Composer form. See solspace.com/docs/freeform/channel_entry_fieldtype As for inline errors in Composer, I'll post a full answer. – Solspace Aug 27 '14 at 13:17
up vote 1 down vote accepted

To have inline errors in Freeform Composer, you need to create a custom Composer Template since the default template does not contain inline error code.

  1. Go to CP => Add-Ons => Modules => Freeform => Composer Templates and create a new Composer Template.
  2. Under the Template Params setting, add your parameters, in particular inline_errors / yes. You can add other parameters if you need more.
  3. In the Composer Template section, you should see the code for a default Composer Template. You will need to add inline error template code similar to what is in the documentation (see http://www.solspace.com/docs/freeform/form/#freeform_error_field_name). Find the part that says:

    {if:else}
        <p>{composer:field_output}</p>
    {/if}
    

    and add the inline error code (arrange to your liking):

    {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 you need inline errors for general errors (eg. captcha not filled in, etc), feel free to also add the {freeform:general_errors} code (see docs) as well in the Composer template where appropriate (eg. at the top of the Composer Template).

  4. Go to the Forms section and click the icon in the "Composer" column to edit your Composer form.
  5. In the top left of the screen, select your newly created Composer Template from the dropdown. Save you form.
  6. Add the Freeform custom field to your custom field group. For this example, let's use my_freeform_field
  7. Now your users can select the Composer form from the Freeform custom field when filling out the entry form.

In your template, you can display the Composer form selected in the Channel Entry my simply calling its name:

{exp:channel:entries /* your parameters */}
   <h3>The form:</h3>
   {my_freeform_field}
{/exp:channel:entries}

Unfortunately there are no parameters for the Freeform custom field. If you need to use different parameters or a different Composer Template (and have these options available in the Freeform custom field), unfortunately that requires a new Composer form to link a new Composer Template. (Feature Requests can be written here)

  • Aaaah - I think it was just the 'Template Params' bit that I couldn't see... knew it would be something simple like that! Thank you! – Tim Jukes Aug 27 '14 at 16:32

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.