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.

Dynamic gravity_form_enqueue_scripts

  1. I've created a function that accepts one parameter, the parameter will serve as the form id,

    how can i create a function or make the gravity_form_enqueue_scripts work using this function..

    function enque_scripts($id)
    {
    gravity_form_enqueue_scripts($id,true);
    gravity_form($id, false, true, true, '', true);
    }

    the gravity form is displaying but the css/js is not loaded..

    Posted 12 years ago on Sunday December 11, 2011 | Permalink
  2. Hi, Ruth,

    It sounds like what you are trying to do is load specific css/js per form. To do this you should use the hook "gform_enqueue_scripts". The documentation for that hook is located at http://www.gravityhelp.com/documentation/page/Gform_enqueue_scripts . You can either call the hook for a specific form id like so "gform_enqueue_scripts_6" with 6 being your form id or you can use "gform_enqueue_scripts" and check for the form id in the function you call like so:

    if ($form["id"] == 1)
    {
      //do something for this form only
    }

    Let me know if you have any questions.

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  3. what im trying to do is make it dynamic as possible..

    the examples on the link you specify is for custom js, but what i only need is to load the GF css/js

    are you saying that my function above will not work?

    what it can do is output the form but not the css/js

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  4. Sorry, I misunderstood what you were trying to do. The css/js isn't displaying because you need to use gravity_form_enqueue_scripts sooner in the page load. So you can use gravity_form_enqueue_scripts in the <head> or before your theme page calls the get_header() function . You won't be able to have the enqueueing and the form in the same function.

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  5. ok, i think i've read something similar about what you have said,

    that the gravity_form_enqueue_scripts should be called before the wp_head()

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  6. Let us know if you still have problems.

    Posted 12 years ago on Tuesday December 13, 2011 | Permalink
  7. I think the problem is solved... You may close this thread

    Posted 12 years ago on Tuesday December 13, 2011 | Permalink

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