<p>You can pass values from other Craft elements or from URL segments, etc to your Freeform forms. Specifically when using with the <a href="http://docs.solspace.com/craft/freeform/v2/overview/fieldtype.html" rel="nofollow noreferrer">Element fieldtype</a>, when wanting to <a href="http://docs.solspace.com/craft/freeform/v2/template-objects/form.html#prop-custattr-returnurl" rel="nofollow noreferrer">override the return URL</a>, you can do something like this:</p>

<pre><code>{{ form.renderTag({
  returnUrl: entry.thankyouUrl
}) }}
</code></pre>

<p>When wanting to <a href="http://docs.solspace.com/craft/freeform/v2/template-objects/form.html#prop-custattr-overridevalues" rel="nofollow noreferrer">override Freeform field data values or options</a>, you can do something like this:</p>

<pre><code>{{ form.renderTag({
   overrideValues: {
      hiddenFieldHandle: entry.id,
      stateSelect: "AZ",
      availability: ["tue", "thu"],
   }
}) }}
</code></pre>

CC BY-SA 4.0
2019-01-21T05:56:30.100Z
2019-01-21T05:56:30.100Z
Solspace
<p>I have an Freeform entry field <code>{{ pageForm }}</code> where the user can select a form to display on the page. </p>

<p>And then in the page template I load the form in to the page using <code>{{ entry.pageForm.render() }}</code>. Cool.</p>

<p>I also want them to be able to choose the return URL from an Entries field e.g <code>{{ entry.formThankyouUrl }}</code>. Is there any way to pass that formThankyouUrl to the renderTag? E.g the below setup would be ideal..</p>

<p><strong>Page template:</strong></p>

<pre><code>{% if entry.formPageForm|length %}
   {% set thankyouUrl = row.formThankYou.one() ?? null %}
   {{ entry.formPageForm.render() }}
{% endif %}
</code></pre>

<p><strong>Form template:</strong></p>

<pre><code>{{ form.renderTag({
  returnUrl: thankyouUrl
}) }}
</code></pre>

<p>The reason I ask is that the default Return URL functionality in freeform is quite limited in that you have to paste in the URL, would be good to select it form a entries dropdown</p>

<p>Thanks</p>

CC BY-SA 4.0
2018-12-09T01:03:53.717Z
Are you using Ajax to update the page and bring in the form the user selects, or just unhiding the form? If so, on thankYouUrl field update on the page, update the return URL with JavaScript. Or, if you mean user = Craft user editing entry and selecting form, you can have the template check if thankyouurl has value and pass the custom return in the render parameters (https://solspace.com/craft/freeform/docs/freeform.form/#render)
Chattervast
<plugin-freeform><solspace><freeform>
Solspace Freeform pass variable to form
# Solspace Freeform pass variable to form

(Asked by: username_0 on 2018-12-06)

I have an Freeform entry field {{ pageForm }} where the user can select a form to display on the page. 
And then in the page template I load the form in to the page using {{ entry.pageForm.render() }}. Cool.
I also want them to be able to choose the return URL from an Entries field e.g {{ entry.formThankyouUrl }}. Is there any way to pass that formThankyouUrl to the renderTag? E.g the below setup would be ideal..
Page template:
{% if entry.formPageForm|length %}
   {% set thankyouUrl = row.formThankYou.one() ?? null %}
   {{ entry.formPageForm.render() }}
{% endif %}

Form template:
{{ form.renderTag({
  returnUrl: thankyouUrl
}) }}

The reason I ask is that the default Return URL functionality in freeform is quite limited in that you have to paste in the URL, would be good to select it form a entries dropdown
Thanks

**Tags:** plugin-freeform, solspace, freeform
> **Comments:**
> **username_1**: Are you using Ajax to update the page and bring in the form the user selects, or just unhiding the form? If so, on thankYouUrl field update on the page, update the return URL with JavaScript. Or, if you mean user = Craft user editing entry and selecting form, you can have the template check if thankyouurl has value and pass the custom return in the render parameters (https://solspace.com/craft/freeform/docs/freeform.form/#render)  

---

## 1 answers

### Answer by username_2 on 2019-01-21. Score: 1 | Accepted answer

You can pass values from other Craft elements or from URL segments, etc to your Freeform forms. Specifically when using with the Element fieldtype, when wanting to override the return URL, you can do something like this:
{{ form.renderTag({
  returnUrl: entry.thankyouUrl
}) }}

When wanting to override Freeform field data values or options, you can do something like this:
{{ form.renderTag({
   overrideValues: {
      hiddenFieldHandle: entry.id,
      stateSelect: "AZ",
      availability: ["tue", "thu"],
   }
}) }}


---

