Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-27T07:44:37.520Z
Answers.LastActivityDate: 2019-02-27T07:44:37.520Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <craft3><relations><redirect><variable><plugin-freeform>
Title: Need help trying to pass a variable of a related entry
ThreadText: # 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
  
  ```TWIG
  {% set priceBracket = entry.relatedAdoptionLink.one() %}
  {% set priceUrl = priceBracket !== null? priceBracket.getUrl() : '' %}
  
  {{ form.renderTag({returnUrl: priceURL}) }}
  
  ```
  
  
  ---
  
  