1

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

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 (solspace.com/craft/freeform/docs/freeform.form/#render) Dec 9, 2018 at 1:03

1 Answer 1

1

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"],
   }
}) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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