Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gravity Forms adding display none

I'm creating a custom template inside my WordPress theme, since my template is a completely different layout than my active theme, the template has it's own header & footer and inside of both I have properly declared wp_head(); and wp_footer(); respectively.

Inside my template code, I am trying to display a gravity form using do_shortcode, but no form shows. When I inspect the area, I can see the form code, but there is a style="display:none" added to the .gform_wrapper div.

As one more note, gravity forms is working perfectly throughout the rest of my site (all pages/posts using the active theme), I only have the problem on my custom template.

Any suggestions are much appreciated.

Thanks

like image 832
user1776729 Avatar asked Jun 23 '13 10:06

user1776729


2 Answers

Although this is an old question it still came up first when I searched for this problem, so I'm adding my solution in case others are searching too. If your theme moves scripts to the footer (frequently recommended for performance reasons) by including one or more of the following lines of code in functions.php:

remove_action('wp_head', 'wp_print_scripts'); 
remove_action('wp_head', 'wp_print_head_scripts', 9);
add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);

you'll need to move the Gravity Forms scripts to the footer as well, so they get called after jQuery. You can do this by adding the following code to your theme's functions.php file:

add_filter('gform_init_scripts_footer', 'init_scripts');
function init_scripts() {
    return true;
}
like image 63
Linn Avatar answered Oct 17 '22 18:10

Linn


This is because you have conditional logic being used on your form. Anytime conditional logic is present the entire form is set to display: none; and then javascript is used to only show the fields that should be shown.

HOWEVER this requires Gravity Forms being able to output the necessary Javascript using the WordPress built in enqueue function... which outputs the Javascript in your footer.

Your theme probably does not have this function call in your theme's footer.php file:

<? php wp_footer(); ?>

This function call, which all themes should have (but many people forget to include), enables plugins to output code in the footer of a theme dynamically. If it isn't present, the theme can't output the necessary code.

This is most likely why your form is not displaying properly.

Answer from: http://www.gravityhelp.com/question/why-is-there-a-style-attribute-of-displaynone-being-added-my-form-isnt-showing-up/

like image 5
Mikael Mälarström Avatar answered Oct 17 '22 19:10

Mikael Mälarström