3

I'm using the standard P&T contact form plugin. I have a website with 3 locales in a folder structure where every locale has its own folder:

Public

-- EN

-- FR

-- NL

The contact form has the following code:

<form method="post" action="" accept-charset="UTF-8" data-abide>
        {{ getCsrfInput() }}
        <input type="hidden" name="action" value="contactForm/sendMessage">
        <input type="hidden" name="redirect" value="thanks?from={fromName}">

        // Rest of code: fields, etc.

</form>

The redirect template is called thanks and it works as it should except that the thanks page is always redirecting to the EN locale. When I manualy navigate my browser to go to the thank you page in another locale it works too. But after submitting the form, it just does not redirect to the current locale.

Update

Removing ?from{fromName} does not resolve the issue

siteUrl is set in the config file:

'*' => array(    
'siteUrl' => array(
                'nl' => 'http://cmgg.buthost.com/nl/',
                'fr' => 'http://cmgg.buthost.com/fr/',
                'en' => 'http://cmgg.buthost.com/en/'
            )
)

Sidenote: the whole website is almost final and everything with the locales is working as it should except the contact form redirect.

3
  • 1
    I'm having this issue as well - did you find a solution?
    – megatrond
    Aug 17, 2015 at 11:24
  • 2 years later and still no solution?! Anyone? I've come across this exact issue, sending me to the EN locale. Aug 7, 2017 at 3:58
  • Sorry, I don't know if I ever found a solution or a workaround. Just checked the project code, but didn't find anything specific and I don't have it running locally anymore to test it. Aug 7, 2017 at 11:47

2 Answers 2

1

Remove 'usePathInfo' => true, from your /craft/config/general.php

This fixed a similar error on my site.

1
  • I don't use that setting in my config. Jun 27, 2015 at 9:40
1

Well you could prepend the current locale to the redirect string with the craft.locale variable

<input type="hidden" name="redirect" value="{{craft.locale}}/thanks?from={fromName}">

In Craft 3 the redirect parameters need to be hashed and craft.locale is deprecated so we need to use craft.app.language. So when using the input tag you could do it like this

{% set redirectParam = craft.app.language ~ '/thanks?from={fromName}' %}

<input type="hidden" name="redirect" value="{{redirectParam | hash}}">

or use the built in helper function

{{ redirectInput(craft.app.language ~ '/thanks?from={fromName}') }}

other option would be to prepend the baseUrl of the current site ( craft3 )

{% set baseUrl = craft.app.sites.currentSite.baseUrl ? craft.app.sites.currentSite.baseUrl : '/' %}

{{ redirectInput(baseUrl ~ '/thanks?from={fromName}') }}

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.