What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Form return_to not working as expected

Form return_to not working as expected

Nelson_0
Shopify Partner
2 0 0

Following the information given in  https://shopify.dev/docs/api/liquid/tags/form#form-return_to
I'm unable to redirect the user after he submits an email via the `newsletter.liquid` section, I can validate that the hidden input tag has been added with the correct URL I want to redirect to.

What happens: After I submit an email I get redirected to `/challenge#contact_form` page with the reCAPTCHA(Issue 2), after I submit "I'm not a robot" I get redirected again to the root page `/?customer_posted=true`

 

Issue 2: I don’t understand why reCAPTCHA is being displayed even though I have all settings disabled.

 

Code changes:
Nelson_0_0-1711645527284.png

Resulting HTML:

Nelson_0_1-1711645561517.png

reCAPTCHA settings:

Nelson_0_2-1711646321720.png

 



Replies 2 (2)

Basfijneman
Shopify Partner
1 0 0

Hi there,

 

Are you testing this locally? Because if so you should test it with the preview link and not with your local link because that will trigger the recaptcha!

I have the same issue where it doesn't let me use a captured variable in the return_to... 
When using a string it works but I need to pass a variable and this doesn't work.. have you tried it with a hardcoded string already?

Nelson_0
Shopify Partner
2 0 0

Yes, I'm testing using the local link.
I have not tested with the hardcoded string since the use case I need is for it to be configurable.

My workaround 🐒🔨 was using the form.posted_successfully? to know when I could force the window location to change via JS.
Ex:

{%- if form.posted_successfully? -%}
  {% if section.settings.redirect_url != blank -%}
    <script type="text/javascript">
      window.location = "{{ section.settings.redirect_url.url }}";
    </script>
  {%- endif %}

...