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 messed up when calling form from theme functions file vs. in post itself

  1. Billmcq
    Member

    If I insert the form in the post manually from the post editor screen, the form looks fine.
    If I use the functions file to automatically call the form on singe post pages for certain categories, the same form displays, but styling is a mess. Now, if I also then manually add the same form in the post editor screen....both forms look fine. Why is it that the form styling is changing depending on what method the form is being inserted into the post?

    Here is my theme function file:

    /** Add a contact form at the end of single posts based on category*/
    add_action('genesis_after_post_content', 'insert_form');
    function insert_form() {
    if (is_single() && in_category(array(3,4,5,6,7,10))) {
    gravity_form(1, false, flase, false, '', true);
    }
    }

    and an example page of the issue:
    http://www.mcqwebdesign.com/demos/tgpackaging/200/cozzoli-air-cleaner-item-1864/

    Posted 12 years ago on Friday July 29, 2011 | Permalink
  2. When you add a form using the function call rather than the shortcode, you need to manually enqueue the styles and scripts.

    Please review this FAQ item:
    http://www.gravityhelp.com/question/my-forms-styles-arent-being-loaded-properly/

    Posted 12 years ago on Friday July 29, 2011 | Permalink
  3. Billmcq
    Member

    thanks for your reply. .I guess that is the issue for sure, but I was using a function to add that, but after looking at source, it does not appear to be adding. It is fairly straight forward...
    Here is the code I used in functions. It successfully adds the form to the appropriate single post pages based on the category number the post comes from, but the second part is not working....it is not adding the the header code.

    /** Add a contact form at the end of single posts based on category*/
    add_action('genesis_after_post_content', 'insert_form');
    function insert_form() {
    if (is_single() && in_category(array(1,3,4,5,6,7,10))) {
    gravity_form(1, true, true, false, '', true);
    }
    }
    add_action('genesis_header', 'insert_form_enqueue');
    function insert_form_enqueue() {
    if (is_single() && in_category(array(1,3,4,5,6,7,10))) {
    gravity_form_enqueue_scripts(1, true);
    }
    }

    It doesn't work even if I skip the conditional for the enqueue. Not sure why this isn't working.

    Posted 12 years ago on Saturday July 30, 2011 | Permalink