Answers.Body: <p>This could potentially be handled a few different ways...</p>
  <p><strong>1. Move the Form Title location</strong></p>
  <p>Remove the Title from the formatting template and set up your main template loading the form to look something like this:</p>
  <pre><code>{% set form = craft.freeform.form('myForm')  %}
  
  {% if showFormTitle %}
     {{ form.name }}
  {% endif %}
  
  {{ form.render }}
  </code></pre>
  <p><strong>2. Wait for Freeform 3.12</strong></p>
  <p>Freeform 3.12 will be going into beta very soon and will have the ability to add something like this to the form payload:</p>
  <pre><code>{{ form.render({ showFormTitle: true }) }}
  </code></pre>
  <p>And in your formatting template, use:</p>
  <pre><code>{% if form.properties.showFormTitle %}
     {{ form.name }}
  {% endif %}
  </code></pre>
  <p><strong>3. Use Conditional Rules feature</strong></p>
  <p>You could use a combination of using the <code>overrideValues</code> parameter, Conditional Logic, and an HTML field with Twig parsing on.</p>
  <ol>
  <li>Go to the form builder for this form.</li>
  <li>Add an HTML field.</li>
  <li>Add the value <code>{{ form.name }}</code> and any other formatting to the HTML block field.</li>
  <li>Check off the <strong>Allow Twig</strong> checkbox.
  <ul>
  <li>If you don't see this option, be sure to upgrade to the latest version of Freeform and go to the <em>Form Builder Settings</em> area (Freeform -&gt; Settings -&gt; Form Builder Settings) and enable the <strong>Allow Twig to be Enabled for each HTML block?</strong> toggle.</li>
  </ul>
  </li>
  <li>Create a hidden field (for purpose of this example, let's give it a handle of <code>showTitleField</code>).</li>
  <li>Go to the Conditional Rules tab in the form builder and add some logic for this. Something like: Show the HTML field only when <code>showTitleField</code> contains a value of <code>show</code>.</li>
  <li>Save the form.</li>
  <li>In your templates, where you call the form, add the <code>overrideValues</code> parameter and add a line for the hidden field. Something like:
  <pre><code>overrideValues: {
     showTitleField: &quot;show&quot;
  }
  </code></pre>
  <ul>
  <li>If you need to do something dynamic with that value, you can check out the guide here for <a href="https://docs.solspace.com/craft/freeform/v3/guides/passing-dynamic-data-to-forms.html" rel="nofollow noreferrer">Passing Dynamic Data to Forms</a>.</li>
  </ul>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-24T10:24:16.230Z
Answers.Text: Wow. That's, uhh, quite a workaround! If I'm understanding it correctly, that's shifting the onus of rendering the form name from the formatting template itself, on to an HTML field _inside_ the form. While quite imaginatave, this isn't practical for the use-case I have as the title and the form fields are somewhat separated, HTML-wise. Also, it's a complex-enough solution that I might as well just clone the formatting template, minus the code for the form title. :-/ Might I submit the ability to pass Twig variables to formatting templates as a feature request? ;)
Answers.UserDisplayName: Sandwich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-24T15:22:35.627Z
Answers.Text: The other option you have would be rather simple... see next answer...
Answers.UserDisplayName: Solspace
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-24T15:29:13.793Z
Answers.Text: @Sandwich I have updated the answer to include some other options.
Answers.UserDisplayName: Solspace
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-24T15:35:10.193Z
Answers.Text: I see that! Option 1 is of course a very simple and sensible solution, however on a site that already has numerous forms scattered about on various pages, it's probably more work than it's worth. Option 2 sounds good, though! Might I suggest the ability to somehow override the form title, not just show or hide it? Perhaps `overrideValues: { name: "Custom Form Title" }`, or perhaps `{{ form.render({ formTitle: [true|false|"Custom Title"] }) }}` ?
Answers.UserDisplayName: Sandwich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-24T17:28:44.040Z
Answers.Text: Sure, I'll make a note about that for FR list - thanks! :)
Answers.UserDisplayName: Solspace
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-21T16:16:51.260Z
Answers.Text: I've got version 3.12.9.1. The code `{{ craft.freeform.form(entry.formField.handle,  formRenderSettings).render({ formTitle: 'hidden' }) }}` results in the error `Neither the property "properties" nor one of the methods "properties()", "getproperties()"/"isproperties()"/"hasproperties()" or "__call()" exist and have public access in class "Solspace\Freeform\Library\Composer\Components\Form" in "__string_template__8dd7283256bc9c330b24d64d52715d2f1c033f64b05cb712c143bff47665e451" at line 19.`
Answers.UserDisplayName: Sandwich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-22T17:34:28.387Z
Answers.Text: Sorry @Sandwich, I can see it isn't working correctly either. We'll look into it and get a fix out tomorrow. :)
Answers.UserDisplayName: Solspace
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-23T17:52:17.533Z
Answers.Text: @Sandwich, this should now be fixed in Freeform 3.12.11. :)
Answers.UserDisplayName: Solspace
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-23T15:01:54.213Z
Answers.LastActivityDate: 2021-08-24T15:28:26.263Z
Answers.LastEditDate: 2021-08-24T15:28:26.263Z
Answers.UserDisplayName: Solspace
Body: <p>I want to be able to toggle the display of a form's Title on or off, without having to resort to using a mostly-identical copy of the formatting template.</p>
  <p>Freeform formatting template:</p>
  <pre><code>{% if showFormTitle %}{{ form.name }}{% endif %}
  </code></pre>
  <p>How can I control the value of <code>showFormTitle</code> from the Twig template that renders the form? This (and all the permutations of it that I've tried) doesn't work:</p>
  <pre><code>{% set showFormTitle = true %}
  {{ craft.freeform.form(myForm).render() }}
  </code></pre>
  <pre><code>{% set showFormTitle = true %}
  {{ craft.freeform.form(myForm).render() with { showFormTitle: showFormTitle } }}
  </code></pre>
  
Tags: <templating><plugin-freeform>
Title: How can I pass a variable to Freeform's formatting template so that it's available to Twig?
ThreadText: # How can I pass a variable to Freeform's formatting template so that it's available to Twig?
  
  (Asked by: username_0 on 2021-08-23)
  
  I want to be able to toggle the display of a form's Title on or off, without having to resort to using a mostly-identical copy of the formatting template.
  
  Freeform formatting template:
  
  ```
  {% if showFormTitle %}{{ form.name }}{% endif %}
  
  ```
  
  How can I control the value of `showFormTitle` from the Twig template that renders the form? This (and all the permutations of it that I've tried) doesn't work:
  
  ```
  {% set showFormTitle = true %}
  {{ craft.freeform.form(myForm).render() }}
  
  ```
  
  ```
  {% set showFormTitle = true %}
  {{ craft.freeform.form(myForm).render() with { showFormTitle: showFormTitle } }}
  
  ```
  
  **Tags:** templating, plugin-freeform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-23. Score: 3 | Accepted answer
  
  This could potentially be handled a few different ways...
  
  **1. Move the Form Title location**
  
  Remove the Title from the formatting template and set up your main template loading the form to look something like this:
  
  ```
  {% set form = craft.freeform.form('myForm')  %}
  
  {% if showFormTitle %}
     {{ form.name }}
  {% endif %}
  
  {{ form.render }}
  
  ```
  
  **2. Wait for Freeform 3.12**
  
  Freeform 3.12 will be going into beta very soon and will have the ability to add something like this to the form payload:
  
  ```
  {{ form.render({ showFormTitle: true }) }}
  
  ```
  
  And in your formatting template, use:
  
  ```
  {% if form.properties.showFormTitle %}
     {{ form.name }}
  {% endif %}
  
  ```
  
  **3. Use Conditional Rules feature**
  
  You could use a combination of using the `overrideValues` parameter, Conditional Logic, and an HTML field with Twig parsing on.
  
  1. Go to the form builder for this form.
  2. Add an HTML field.
  3. Add the value `{{ form.name }}` and any other formatting to the HTML block field.
  4. Check off the **Allow Twig** checkbox.
     * If you don't see this option, be sure to upgrade to the latest version of Freeform and go to the *Form Builder Settings* area (Freeform -> Settings -> Form Builder Settings) and enable the **Allow Twig to be Enabled for each HTML block?** toggle.
  5. Create a hidden field (for purpose of this example, let's give it a handle of `showTitleField`).
  6. Go to the Conditional Rules tab in the form builder and add some logic for this. Something like: Show the HTML field only when `showTitleField` contains a value of `show`.
  7. Save the form.
  8. In your templates, where you call the form, add the `overrideValues` parameter and add a line for the hidden field. Something like:
  
     ```
     overrideValues: {
        showTitleField: "show"
     }
  
     ```
  
     * If you need to do something dynamic with that value, you can check out the guide here for [Passing Dynamic Data to Forms](https://docs.username_1.com/craft/freeform/v3/guides/passing-dynamic-data-to-forms.html).
  
  > **Comments:**
  > **username_0**: Wow. That's, uhh, quite a workaround! If I'm understanding it correctly, that's shifting the onus of rendering the form name from the formatting template itself, on to an HTML field _inside_ the form. While quite imaginatave, this isn't practical for the use-case I have as the title and the form fields are somewhat separated, HTML-wise. Also, it's a complex-enough solution that I might as well just clone the formatting template, minus the code for the form title. :-/ Might I submit the ability to pass Twig variables to formatting templates as a feature request? ;)  
  > **username_1**: The other option you have would be rather simple... see next answer...  
  > **username_1**: @username_0 I have updated the answer to include some other options.  
  > **username_0**: I see that! Option 1 is of course a very simple and sensible solution, however on a site that already has numerous forms scattered about on various pages, it's probably more work than it's worth. Option 2 sounds good, though! Might I suggest the ability to somehow override the form title, not just show or hide it? Perhaps `overrideValues: { name: "Custom Form Title" }`, or perhaps `{{ form.render({ formTitle: [true|false|"Custom Title"] }) }}` ?  
  > **username_1**: Sure, I'll make a note about that for FR list - thanks! :)  
  > **username_0**: I've got version 3.12.9.1. The code `{{ craft.freeform.form(entry.formField.handle,  formRenderSettings).render({ formTitle: 'hidden' }) }}` results in the error `Neither the property "properties" nor one of the methods "properties()", "getproperties()"/"isproperties()"/"hasproperties()" or "__call()" exist and have public access in class "username_1\Freeform\Library\Composer\Components\Form" in "__string_template__8dd7283256bc9c330b24d64d52715d2f1c033f64b05cb712c143bff47665e451" at line 19.`  
  > **username_1**: Sorry @username_0, I can see it isn't working correctly either. We'll look into it and get a fix out tomorrow. :)  
  > **username_1**: @username_0, this should now be fixed in Freeform 3.12.11. :)  
  
  ---
  
  