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.


1 Answer 1


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}) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.