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.

Trouble embedding form into template file

  1. Code used:

    //Code in header.php
    
    //shows form if homepage
    <?php if (is_page('home')) { ?>
    <div id="main_eval_form">
    <?php echo do_shortcode('[gravityform id="1" name="Gravity Forms Test" ajax="true"]'); ?>
    </div>
    <?php } ?>
    
    //shows form on internal pages if button is clicked (jquery)
    <div id="sub_eval_form">
    <?php echo do_shortcode('[gravityform id="1" name="Gravity Forms Test" ajax="true"]'); ?>
    </div>

    If you look at the source code from the homepage or any internal page, you can clearly see that the form is present in the source, but I can't figure out why it isn't present when rendered in the browser.

    Live site ---> HERE

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  2. David Peralty
    Administrator

    Your theme is using JQuery 1.3.2 and WordPress ships with 1.7.2 by default. Gravity Forms requires 1.6 or above to render form elements. Once that is resolved, I can take a look again to see if there are any other issues.

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  3. Just updated jquery to 1.7.2. Thanks for looking into this!

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  4. Not sure if this matter or helps but I'll share it in hopes that it will. While building the form, I created a page titled "Testing" and embedded the shortcode into the page. everything worked fine and still does IF (big if) i remove the do_shortcode call in the header.

    Again, not sure if that's helpful...

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  5. David Peralty
    Administrator

    Wait, why is your shortcode in your header file? Can you start from scratch explaining what you are trying to do so that I can better understand the result you are looking for?

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  6. The site's primary purpose is to generate leads by offering a free customized (based on their input) bankruptcy evaluation. The home page is static with the form above fold and ready for input. There is, or will be a fair amount of information on the site as well. For each of the internal pages, I have it set up so that the form is "hidden" and then appears only when a user clicks on the the button in the right sidebar.

    You can see my entire header.php file HERE

    Would I be better off placing the shortcode in the page.php file? I was under the impression that shortcodes would work anywhere on a php page between the body tags.

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  7. David Peralty
    Administrator

    Okay, so can you preview your form? You mentioned it was working on a WordPress page? Is this correct? Are you using conditional logic in your form? Can you remove your ajax=true call from your shortcode for testing? Are you using the latest WP and GF versions?

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  8. I can preview my form, it will work on a wordpress page if I remove the internal page specific do_shortcode from the header. You can see the form working on a page HERE

    I'm using current versions of wordpress (3.4.1) and Gravity forms (not sure the version but I updated a couple of days ago via the wordpress dashboard)

    I did try removing ajax=true, no change...

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  9. David Peralty
    Administrator

    Okay, would you be willing and able to send me admin login details to peralty@rocketgenius.com and I'll log in and see what I can do?

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  10. sure. I also tried changing the theme to twentyten and then embedding the shortcode...it didn't work there either so my guess is that it's not a theme issue although i could be wrong.

    Posted 7 years ago on Thursday August 2, 2012 | Permalink
  11. David Peralty
    Administrator

    For anyone looking for help with a similar issue:
    I changed it to use the PHP embed code instead of the do shortcode.
    http://www.gravityhelp.com/documentation/page/Embedding_A_Form

    I also moved all of Gravity Forms' JavaScript calls to the header because they were in the footer. Lastly there was two calls to JQuery, so I removed wp_footer temporarily to fix the issue. The theme author should be contacted and asked to put the JQuery call only in the header and only if it needs it.

    Posted 7 years ago on Thursday August 2, 2012 | Permalink

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