<p>This is how it could look like from Twig point of view. I don't know if the Solespace part is correct</p>

<pre class="lang-TWIG prettyprint-override"><code>{% set priceBracket = entry.relatedAdoptionLink.one() %}
{% set priceUrl = priceBracket !== null? priceBracket.getUrl() : '' %}

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

CC BY-SA 4.0
2019-02-27T07:44:37.520Z
2019-02-27T07:44:37.520Z
Robin Schambach
<p>On my page, I have a form which is using Freeform (Solspace). </p>

<p>I'm attempting to setup a custom redirect URL for the form. The form will apply to numerous entries in a channel and some will require different redirect URLs. The main channel in question (Animals) has a relation field which relates it to another channel (Adoption Price). This channel contains a URL field which ideally, I would like the user to be redirected to upon submitting the form. Below is what I have tried so far but with no luck. </p>

<pre><code>  //Setting the variable

  {% for priceBracket in entry.relatedAdoptionLink %}
      {% set priceURL = priceBracket.adoptionPriceLink %}       
  {% endfor %}

  //The Form

    {% set form = craft.freeform.form("animalAdoptionForm", {
        labelClass: "form-label",
        inputClass: "form-control",
        instructionsBelowField: true,
        overrideValues: {
          animalToAdopt: entry.title,
        }
    }) %}

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

<p>Can anybody help me out with this? Setting the variable directly via the entry would be more straight forward but I'm trying to pull the information I need from a relation in another channel.</p>

<p>Thanks</p>

<craft3><relations><redirect><variable><plugin-freeform>
Need help trying to pass a variable of a related entry
# Need help trying to pass a variable of a related entry

(Asked by: username_0 on 2019-02-25)

On my page, I have a form which is using Freeform (Solspace). 
I'm attempting to setup a custom redirect URL for the form. The form will apply to numerous entries in a channel and some will require different redirect URLs. The main channel in question (Animals) has a relation field which relates it to another channel (Adoption Price). This channel contains a URL field which ideally, I would like the user to be redirected to upon submitting the form. Below is what I have tried so far but with no luck. 
  //Setting the variable

  {% for priceBracket in entry.relatedAdoptionLink %}
      {% set priceURL = priceBracket.adoptionPriceLink %}       
  {% endfor %}

  //The Form

    {% set form = craft.freeform.form("animalAdoptionForm", {
        labelClass: "form-label",
        inputClass: "form-control",
        instructionsBelowField: true,
        overrideValues: {
          animalToAdopt: entry.title,
        }
    }) %}

    {{ form.renderTag({returnUrl: "{{priceURL}}"}) }}

Can anybody help me out with this? Setting the variable directly via the entry would be more straight forward but I'm trying to pull the information I need from a relation in another channel.
Thanks

**Tags:** craft3, relations, redirect, variable, plugin-freeform


---

## 1 answers

### Answer by username_1 on 2019-02-27. Score: 0 | Accepted answer

This is how it could look like from Twig point of view. I don't know if the Solespace part is correct
{% set priceBracket = entry.relatedAdoptionLink.one() %}
{% set priceUrl = priceBracket !== null? priceBracket.getUrl() : '' %}

{{ form.renderTag({returnUrl: priceURL}) }}


---

