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.

Conditional Logic Fields Breaking Form

  1. Ben
    Member

    Hello,

    I currently have a form created and it's working great. However, I'm having trouble getting conditional logic working. The form is split into two different pages. The first page has a check box that the use has to tick to agree to our terms and conditions. I'm trying to set conditional logic to prevent the second page from showing without that check box being ticked.

    When I enable next button conditional logic on the page break divider, my form simply stops displaying at all on my website. The same thing happens if I enable conditional logic on any of the other form fields.

    Any Ideas?

    Thanks,
    Ben

    Note: I'm currently calling the form in a php file using the following code:

    <?php echo do_shortcode('[gravityform id=3 name=Contribute title=false description=false ajax=false]'); ?>

    Posted 10 years ago on Saturday October 15, 2011 | Permalink
  2. You need to manually enqueue your scripts in the theme when using the php function call to embed the form. That's why the form doesn't show when you enable conditional logic - the conditional logic script isn't being loaded.

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

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

    Posted 10 years ago on Saturday October 15, 2011 | Permalink
  3. Ben
    Member

    Thanks for the quick reply, but I'm sorry, I'm not really much of a coder. I've updated the embed code to the correct syntax below, but I'm having trouble with the gform_enque_scripts code.

    I'm getting the following error:
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'enqueue_custom_script' was given in /home/primeh2/public_html/ophthopedia/wordpressv2/wp-includes/plugin.php on line 405

    With the following embed code:
    <?php gravity_form(3, $display_title=false, $display_description=false, $display_inactive=false, $field_values=null, $ajax=false, $tabindex); ?>

    And the gform_enque_scripts code. This is what's causing the error. I know this is the wrong code, but I'm not sure how to fix it. I'm assuming I'm supposed to call the actual conditional logic script with a variation of this code, but I'm not sure how. Also, what does the 10 and the 2 indicate?:
    <?php
    add_action("gform_enqueue_scripts", "enqueue_custom_script", 10, 2);
    ?>

    Thanks,
    Ben

    Posted 10 years ago on Sunday October 23, 2011 | Permalink
  4. Ben
    Member

    I think I'm a little closer to having the right code now. Here's what I have:
    http://www.pastie.org/2747411

    I'm tyring to display the form on this page:
    http://www.ophthopedia.org/wordpressv2/?page_id=6

    Thanks,
    Ben

    Posted 10 years ago on Sunday October 23, 2011 | Permalink
  5. Ben
    Member

    Ooops. That was silly of me. I now have the following code in my custom_functions.php file in my Thesis theme and the form is now working with conditional logic:
    <?php
    gravity_form_enqueue_scripts(3, true);
    ?>

    Do you foresee any problems if I just leave it calling from the custom_functions.php file or should I make a hook that makes it call from the header?

    -Ben

    Posted 10 years ago on Sunday October 23, 2011 | Permalink
  6. It's fine in custom_functions.php. It will enqueue the scripts on all pages, unless you make provisions to load it conditionally.

    Posted 10 years ago on Monday October 24, 2011 | Permalink