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.

Consistently reliable way to get form values in pre_submission hook

  1. JohnC28
    Member

    What's the best way to get at form values in the pre_submission hook?

    I know I can use $_POST['input_5'] or whatever, but that isn't very maintainable.

    Also, if I edit my form, the id will change.

    Is there a better approach?

    Posted 14 years ago on Monday February 7, 2011 | Permalink
  2. Hi John, the $_POST is currently the only way to get the entry values during the gform_pre_submission hook. At this point in the process Gravity Forms has not retrieved the entry values (with a few exceptions) and when it does, it too uses the $_POST.

    Posted 14 years ago on Monday February 7, 2011 | Permalink
  3. JohnC28
    Member

    Hi David

    >At this point in the process Gravity Forms has not retrieved the entry values
    So is it better to wait for a later hook?

    I'm creating a new user, a new post, possibly a new category and sending emails so I need a fair amount of what's in the form (and it's too custom to use your other plug-ins).

    It's all working but I don't like the hardcoded elements of the code - we've already changed the form structure twice and it means that no changes can be made using the GF interface since it now relies too much on underlying code.

    John

    Posted 14 years ago on Monday February 7, 2011 | Permalink
  4. I understand the predicament. One hack-ish way I've added flexibility to this in the past is to use the 'cssClass' property of the field to identify it. For example, if you need to know which field is the username field, just add a class in the admin for the field that will be used as the username. Then the code will be dependent on the class (which could then be updated in the admin freely) without be depending on a field ID.

    Posted 14 years ago on Monday February 7, 2011 | Permalink

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