I have a Solspace Freeform Pro form built with Freeform Composer. I'm displaying this form within a channel entry using the Freeform Form fieldtype. This generates the full form according to the Composer template specified. Is there any way to display the form's name or ID from within the tag (or somewhere else)?

The current output looks something like <form action="http://[my-url-here]/?ACT=34" accept-charset="utf-8" method="post">

I would like to target certain Composer forms via Javascript and need a way to identify them.

Thanks, Brady

up vote 3 down vote accepted

You can create your own custom Composer Templates in Freeform, which allows you to pass parameters and variables similar to if you used {exp:freeform:form} or {exp:freeform:composer} in a template.

In the Freeform CP. Go to "Composer Templates" and create a new template. Under Template Params, you can add parameters, such as an id or class to your form:

enter image description here

Then, in the Composer editor ("Forms" section, after clicking the edit icon under the "Composer" column), make sure to select your custom Composer Template from the top right dropdown:

enter image description here

On your template, where the Freeform custom field is displayed, your form should then have the parameters that you applied in the Composer Template, eg id="", class="", etc. You can then target your form with javascript using id/class, for example.

  • This works; I'd love to see an option in the future to dynamically access the form ID (otherwise I'll end up with many duplicate Composer templates). Thanks. – Brady F Feb 25 '15 at 15:03

All you need to do is add either of these parameters

form:name="YOUR_FORM_NAME"
form:id="YOUR_FORM_ID"

Documentation is available here: http://www.solspace.com/docs/freeform/composer/#parameters

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.