4

Kind of feel silly having to ask this but I cannot for the life of me get a success message to display after the redirect when the Contact Form submits.

I just am not sure how to call it in the template view.

I have tried various things like this:

{% set success = craft.config.get('successFlashMessage', 'contactform') %}

{% if success %}
  <div class="resp"><h3>{{ success }}</h3></div>
{% endif %}

But just cannot seem to grab it.

I did look at the documentation on Github and was not able to find it.

7
  • 1
    Is there a particular reason you want to use flash and not a redirect hidden input? github.com/pixelandtonic/ContactForm#redirecting-after-submit
    – Brad Bell
    Feb 3 '16 at 0:24
  • No, I just cannot get it to display a message either way, I would like it to stay on the same page but it does not absolutely have to. Feb 3 '16 at 23:01
  • So you're saying even if you add a <input type="hidden" name="redirect" value="success">, you don't get redirected to /success?
    – Brad Bell
    Feb 3 '16 at 23:54
  • The redirect works fine, but there is no message, sorry if it is unclear what I was asking, I am trying to figure out how to display a "your message has been sent" type message on the screen when the message has been successfully sent. Feb 4 '16 at 0:32
  • Ahh, if you're redirecting to a "success" template, then you can just hard code the "your message has been sent" message into the template. If there was a problem sending the email, the user is going to get an error page (either one supplied by you or a default Craft one)
    – Brad Bell
    Feb 4 '16 at 0:34
4

You can see in the code for the plugin on GitHub that it sets a 'notice':

craft()->userSession->setNotice($settings->successFlashMessage);

As the official documentation mentions, this can later be grabbed with the following code:

{% set message = craft.session.getFlash('notice') %}

Then used as a normal message thereafter.

{{ message }}
1
  • Are there new URLs for the referenced links, here?
    – buck1112
    Oct 8 '18 at 21:10

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.