Custom Form Redirect URL based on CMS value

Hello is there a way to set a Redirect URL of a Webflow Form from a CMS value?

Not natively in Webflow, no.

But you do have some options if you put a tad bit of effort into it.

If you do all of this on a CMS Collection page you’ll have access to the CMS values.

Javascript Approach:

Then you could take control of the form submit with Javascript and do this client side.

Here is some example Javascript code from one of my screencasts walking through something similar.

Make (Integromat) Approach:

Or you could submit your form (and the value in a hidden field) to a free Make (Integromat) account.

This is almost always the better approach.

Submit the form to a Webhook and create a response module that tells the web browser to redirect to any page you’d like.

Here’s a screencast walking through how to do this with Make (Integromat) Webhooks.

This one shows you how to use Javascript to display the success / error message. Not 100% what you’re looking for:

But this tutorial has a section showing how to setup the Webhook response module (scroll down a little) and redirect the web browser:

I’m assuming the form is on a collection page, and that the redirect URL you want is already in that collection.

Put an ID like booking-form directly on your form element ( not the form block element, but the form element ).

image

Then in your </body> you can drop in a bit of jquery to set that redirect;

$(function() {
  const $form = $("#booking-form");
  $form.attr("redirect") = " YOUR VAR HERE ";
  $form.data("redirect") = " YOUR VAR HERE ";
});

On a collection page, you’ll see that you can insert collection fields where YOUR VAR HERE is indicated. Note that Webflow emits FORM HTML including both a redirect and a data-redirect attribute, so we’re updating both, to be complete.

If this form is inside of a collection list, the approach will be similar however you’ll need to get a bit more creative on targeting your form. You can’t reliably use ID’s there since you’ll have N copies of that same form.

Hi Michael,

I managed to update the redirect and data-redirect attributes when I clicked on a set of radio buttons. I can see that when I inspect the source code. However, when I clicked the submit button I was not redirected to the new URL in the redirect attribute but to the original redirect URL.
This is the submit button <input type="submit" data-wait="Please wait..." value="Go →" class="button next w-button">.

Would you know why the form doesn’t redirect to the new URL?

I really appreciate any help you can provide.

I can’t see your site without a readonly link, but it sounds like you’re trying to use Webflow’s default form handler action along with redirects. I’m not sure what that would result in.

Depends on what you’re trying to do with your form, but you may need to write some script to process your form data and then manually redirect to where you want the form to go.