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.

Form not displaying using PHP call

  1. jonfoster
    Member

    Hi,
    I'm trying to put a form on my 404 page through the PHP function call method, however I cannot get ANYTHING to display.

    The code of my 404 page is:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header();
    ?>
    
    </header>
    <!-- header -->
    
    <div class="pagemid <?php sidebaroption($post->ID); ?>">
    <div class="topshadow">
    	<div class="inner">
    
    	<div id="mainfull">
    		<!-- breadcrumb -->
    		<?php  $breadcrumbs=get_post_meta($post->ID, 'breadcrumbs_display', true);
    		 if($breadcrumbs == '') { ?>
    		<div id="breadcrumbs">
    		<?php include (TEMPLATEPATH . "/breadcrumb.php"); ?>
    		</div>
    		<?php } ?>
    		<!-- breadcrumb -->
    
    		<div class="content">
    			<h1 class="aligncenter" style="font-size:100px;">Content not found</h1>
    			<h4 class="aligncenter"><?php _e('<p>We are sorry but the content you are attempting to access was not found on this site.</p><p>If you are looking for your Street Association, please <a href="/" class="dots">visit the homepage</a> and follow the instructions there.</p><p>Other information can be found using the links at the very top of this page.</p><p>If you came to this page from another page of this site or a search engine, please fill in the form below so that we can look into the error.<br />Thank you.</p>','versatile_front')?></h2><?php gravity_form(2, true, true, false, '', false); ?>
    		<div class="divider"></div>
    		<!-- content -->
    	</div>
    	<!-- main -->
    
    	</div>
       	<!-- inner -->
    </div>
    </div>
    <!-- pagemid -->		
    
    <div class="clear"></div>
    <?php get_footer(); ?>

    The form is definitely active, and shows up fine in posts and pages.

    Any help greatly appreciated.

    Thanks
    Jon

    Posted 13 years ago on Saturday June 4, 2011 | Permalink
  2. Are you using conditional logic in your form? If so, you need to make sure the form scripts are enqueued properly.

    When embedding a 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 Saturday June 4, 2011 | Permalink
  3. jonfoster
    Member

    Hi,
    Yes, I'm using conditional logic.

    When I add that script I get this error:
    Fatal error: Call to undefined function gravity_form_enqueue_scripts() in ..../header.php on line 53

    Posted 13 years ago on Saturday June 4, 2011 | Permalink
  4. @jonfoster What version of Gravity Forms are you using? If that function doesn't exist you must be running an older version. Make sure you are running the latest version of the plugin.

    Posted 13 years ago on Sunday June 5, 2011 | Permalink
  5. I'd like to suggest that you add some more details to the docs about where this function needs to be called. The docs make no mention of header.php or wp_head() at the moment, at least not on this page:
    http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts

    Posted 13 years ago on Monday June 6, 2011 | Permalink
  6. jonfoster
    Member

    Not sure what version I'm using, but the update settings page says "Your version of Gravity Forms is up to date." and I only downloaded it last week - so presumably I'm ok.

    Posted 13 years ago on Tuesday June 7, 2011 | Permalink
  7. jonfoster
    Member

    Turns out I needed <?php gravity_form_enqueue_scripts(2, false); ?> with the arguments for it to work.

    Thanks
    Jon

    Posted 13 years ago on Tuesday June 7, 2011 | Permalink