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.

Submitting Data to 3rd Party Required Name Attribute

  1. jfriedman

    I have come to understand that there is no way to change the name attribute on the form fields. This is a big problem for me.

    I'm using Gravity Forms on a multisite installation and need to know how I can have users create forms and have the data submit to a 3rd party application. I need to be able to tell the User Admin how to add a parameter that will tell me that "First Name" is actually "first_name".

    Right now when I look at the $entry var values this is what I get.
    id 13,
    form_id 1,
    date_created 2012-08-21 16:00:02,
    is_starred 0,
    is_read 0,
    ip ::1,
    source_url http://localhost/,
    post_id ,
    currency USD,
    payment_status ,
    payment_date ,
    transaction_id ,
    payment_amount ,
    is_fulfilled ,
    created_by 1,
    transaction_type ,
    user_agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1, status active,
    1 Jesse,
    2 Friedman,
    4 (401)555-5555,
    5 ,
    6.3 ,
    6.6 ,

    Now I could obviously code something using the gform_after_submission hook to turn the $key "1" into "first_name" then submit it. Sounds easy enough...

    The problem is I won't know what 1 equals.

    I thought about using jQuery to rewrite the name attribute on the input using a css class on the parent li. That opened another can of worms because the form stopped validating.

    Then I thought about using the query string functionality but it only allows for GET. On that note is there a hook that will grab those values before the form is submitted or validated? If so what am I looking for?

    Is there anyway you can think that would give me the ability to know what field is which without having prior knowledge of the form markup?

    Posted 9 years ago on Tuesday August 21, 2012 | Permalink
  2. Your attempt to use the gform_after_submission hook and turn $key "1" into "first_name" then submit it is how you will need to do it. To be able to determine that "1" is the First Name you have a couple of options.
    1- You could use the class attribute (Field Editor -> Advanced Tab -> CSS Class Name) to give the field a custom "name" and then check that class name in your gform_after_submission hook to find out which field is which. This would work well if you don't have to add any custom class to your fields and don't mind having the extra css class in the markup. If you do, you could use option 2

    2- Create a custom setting (Field Name) that would be displayed on all your fields and allow you to give the field a name. See following doc page:
    You would then look at this setting (instead of the css class setting) in the gform_after_submission hook to determine which field is which.

    I hope this helps.

    Posted 9 years ago on Tuesday August 21, 2012 | Permalink
  3. jfriedman

    Thanks Alex

    I would prefer to do this with Option 2 since it seems more semantic. I understand that I'll be making a new field in the form field addition section right? So essentially under the "Advanced" tab under class name I could make a new field and call it "3rd Party Attribute Name" or something to that effect. Then the User Admin could put a string in that field that would give me a relationship.

    My question is how does that translate to either data in the $entry string or HTML markup when the form is created? Also I need this to be a global solution for all forms created now and in the future.

    Posted 9 years ago on Tuesday August 21, 2012 | Permalink
  4. Your first paragraph is correct.

    This information will not be stored in the $entry object and it won't be displayed in the HTML markup. You will get it from the $form object. So in your gform_after_submission hook, you will loop through the form["fields"] array looking for your custom attribute (i.e. $form["fields"][0]["ThirdPartyName"]). When you find the field, you can get the field ID and plug it into the $entry object to get the user submitted value.
    This solution would work for existing and new forms.

    Posted 9 years ago on Tuesday August 21, 2012 | Permalink
  5. jfriedman

    I just read this again, are you actually suggesting that I change the name attribute from "input_1" to "first_name" with jQuery? I did this once already but it broke validation.

    Posted 9 years ago on Tuesday August 21, 2012 | Permalink
  6. No, I am not. Changing the input name with jQuery will mess things up. What I am suggesting is a way for you to create a new setting so that admin users can give fields a third party name. You can then use that third party name in the gform_after_submission hook to read the submitted field value without needing to know the field ID.

    Posted 9 years ago on Thursday August 23, 2012 | Permalink
  7. jfriedman

    Got it done, thanks for the help

    Posted 9 years ago on Wednesday August 29, 2012 | Permalink

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