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.

How do I get the Entry object from my pre_render function

  1. I'm hooking in to my form with gfrom_pre_render_1 - in this hook, I'm changing a dropdown to dynamic options populated from a custom post type. This works perfect. Yay.

    However, now my problem is, if the form is submitted with errors, the form re-renders with non of the selected dropdowns.

    I'd like to know if there's a static method or some way of getting the Entry object from my pre_render function so I can check and mark the selected options, selected again on submission error.

    Also, I'm getting a Missing argument error with the gform_after_submission hook. Using the latest release: 1.6.4.3

    add_action("gform_after_submission_4", "book_after_submission");
    function book_after_submission($entry,$form) {
    	var_dump($entry);
    	var_dump($form); die();
    }
    Posted 13 years ago on Sunday May 20, 2012 | Permalink
  2. The entry object is not created until the form is successfully submitted, so you will need to use the $_POST variable to get the currently selected value. It will look something like $_POST["input_4"], where 4 is your field ID.

    As far as the "Missing argument error", try changing your add_action() line to the following:

    add_action("gform_after_submission_4", "book_after_submission", 10, 2);
    Posted 13 years ago on Monday May 21, 2012 | Permalink
  3. Thanks Alex. Inspecting the $_POST variable did the trick!

    Posted 13 years ago on Tuesday May 22, 2012 | Permalink
  4. Awesome, glad you are good to go!

    Posted 13 years ago on Tuesday May 22, 2012 | Permalink

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