PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Need to show Confirmation Message outside the default form

  1. freqman24
    Member

    I have the GForm inside a collapsible object so it is not viewable unless you click it open.

    The thing is once the form is submitted the page refreshes and closes the object so I'm unable to see the Confirmation message.

    <a  href="#" onclick="xcollapse('X000');return false;">Submit Post</a>
    <div id="X000" style="display: none; background: transparent;position:relative;">
    <?php gravity_form(1, true, true); ?>
    </div>

    Is there a way to call the confirmation message for a form outside of the gform shortcode. So that it only appears to confirm? Something I can put in the header or somewhere else in the template.

    Posted 13 years ago on Monday July 11, 2011 | Permalink
  2. The easiest solution is going to be to turn AJAX on where you are calling the form. If you call the form with AJAX then it's not going to refresh the page when it submits, which is more ideal for situations like this.

    Documentation for embedding a form can be found here:

    http://www.gravityhelp.com/documentation/page/Embedding_A_Form

    Be sure to look at the function call parameters, you can tell it to display using AJAX with the correct parameters.

    Since you are calling the form via the function call and not the shortcode in a page or post you will have to also make sure you are enqueuing the necessary scripts and CSS. To enqueue the necessary scripts and CSS you would use the gravity_form_enqueue_scripts function call documented here:

    http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts

    You would place that function call in your themes functions.php, ideally you can wrap it in an if statement checking for the post or page id so it only outputs if it's on the page containing that form... unless of course the form is being output on every page and then it's fine to include it globally.

    Posted 13 years ago on Monday July 11, 2011 | Permalink
  3. freqman24
    Member

    Thanks carl that Ajax suggestion...works great. I think. You went on to talk about the enqueue scripts but I didn't need to do that it appears. Does this mean the plugin is running the scripts globally already? I only need them to load for this specific page don't I? Is that the setting that I can switch off in the admin?

    Posted 13 years ago on Monday July 11, 2011 | Permalink
  4. No, if you want to selectively enqueue the scripts you'd have to do so from wherever you have implemented the gravity_form_enqueue_scripts function call. So you'd have to wrap that function call in an if statement to check the post/page id. If you are using the function call to display the form, you would want to use the enqueue scripts function call to be sure any necessary scripts for that form are enqueued.

    The form function call doesn't do that because WordPress can only enqueue scripts at certain points in it's code execution, and usually the form function call is used somewhere in the theme where it's too late to enqueue. Typically the enqueue scripts function call should go in your themes functions.php file.

    Posted 13 years ago on Monday July 11, 2011 | Permalink
  5. Did you already have a form on the page.. in the footer or sidebar widget perhaps? That would explain why the scripts were already enqueued there.

    Posted 13 years ago on Monday July 11, 2011 | Permalink
  6. freqman24
    Member

    I'm using Canvas Wootheme. I think that is why, no? Doesn't it already support GF?

    Posted 13 years ago on Tuesday July 12, 2011 | Permalink
  7. WooThemes already include some default Gravity Forms styles, but I'm pretty sure they don't enqueue any of the scripts in the theme itself. Strange.

    Posted 13 years ago on Tuesday July 12, 2011 | Permalink
  8. @freqman24 Yes, it supports Gravity Forms. But what you are trying to do is use the function call, which means you have to then enqueue the necessary scripts. The theme isn't going to do this automatically because it's only necessary in this situation and the enqueue function call is specific to the form you are displaying.

    Most users use the shortcode in a page or post, which typically works out of the box with most themes. The function call is a more advanced developer oriented method for working with the forms.

    Posted 13 years ago on Tuesday July 12, 2011 | Permalink
  9. freqman24
    Member

    Thanks for the help throughout. I've tried adding the scripts and it behaves the same except for the fact that with scripts in the header I now get a loading image appear beside the submit button. The other behavior was the same. The collapsible object didn't close and I was able to see the confirmation message and the form was submitted successfully. maybe i'm missing what the expected behaviour is of using ajax. either way, it's working. Can you see any reason that something is wrong with this way of set up?

    Posted 13 years ago on Wednesday July 13, 2011 | Permalink
  10. Can you a post a link to the page so we can see the form and see the issue happening?

    Posted 13 years ago on Wednesday July 13, 2011 | Permalink