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.

Styling a hard coded form

  1. Hello-

    I am having a problem making my form look like the others when I hard code into the blog template. I am using the following code:

    <?php gravity_form($id=2, $display_title=true, $display_description=true, $display_inactive=false, $field_values=null, $ajax=false); ?>
    	        <?php gravity_form_enqueue_scripts(2, true);?>

    When I insert directly into the post from the UI in WordPress, all looks great, but when I hard code the form into the blog template it loses all formatting. Any ideas?

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  2. When embedding a Gravity Form via a function call you must also manually include the necessary Gravity Forms related Javascript and CSS via the built in WordPress enqueue capabilities. Gravity Forms does not include these by default when calling a form via a function call and they are necessary for forms that contain conditional logic or the date picker field.

    We strongly recommend you enqueue the scripts rather than including them as hard-coded calls in your theme. Implementing it this way will insure that Gravity Forms does not include them on the page if they are already present. It is also a good practice to only load these scripts on the front end.

    Gravity Forms 1.5 introduced the gravity_form_enqueue_scripts function which allows you to easily enqueue the necessary Gravity Forms' scripts and styles when manually embedding a form. This is also useful if you are using a GF widget and do not wish for the styles and scripts to be loaded inline.

    You will need to manually enqueue the scripts and CSS by placing a short script block in your theme's header.php file.

    You can find more information at the URLs below

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

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

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  3. Thank you for your reply. I placed the code in the header as instructed, but now I get a piece of code displaying on the website above the header...I don't think I am doing this right.

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink
  4. I figured it out!

    Thanks for all...

    Posted 13 years ago on Tuesday May 10, 2011 | Permalink

This topic has been resolved and has been closed to new replies.