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.

Custom Field Name

  1. I would like Custom Field Names to be an option.
    so instead of...
    name="input_1"
    I could have
    name="firstName"

    That would allow me to write custom pre post hook logic that targets $_POST['firstName']
    for all my forms regardless of the position of the FirstName field.

    It's a pain to figgure out what field name to target and if you move things around your field name changes...

    So please give me the option to change the field name.

    Posted 14 years ago on Friday November 26, 2010 | Permalink
  2. Ok...this might not be *exactly* what you are looking for but you can dynamically change field names with javascript.

    ie:

    inputs = document.getElementsByTagName("input");
    for(i=0; i < inputs.length; i++){
    inputs[i].name="my_name";
    }

    quick edit:

    You would need to call this type of javascript before the submit or posting of the form. Ideally you would use it with jquery or even a simple

    <code><body onLoad=&quot;javascript_function&quot; ></code>

    Otherwise the post data of the form will send with the originally named fields.

    bah. Edit # 2:

    If you are terribly bored you can always write up a javascript class that changes the element name to the class name. You CAN change the css class name with GF so..it would then matter very little how you arranged your fields.

    Last edit, I promise.

    A long way to do it is to send the data using javascript. You would still need a similar function as listed above, but just pointing out that it is an option.

    Posted 14 years ago on Friday November 26, 2010 | Permalink
  3. Thanks for the suggestion.. it's a migty workaround (modifying the dom with javascript) I would probably want to do it with custom classes and then get the javascript to rename according to custom class name..

    yeah.. It's a bit much..

    I really think they should apply a custom id option.

    Posted 14 years ago on Friday November 26, 2010 | Permalink
  4. You know what.. here's what I did to produce a solution to my problem..

    I wanted to set session values based on a common identifier (label or id) that's why I was asking for the custom ID..

    But after taking a second look at the hook function provided in the documentation I found a way to do what I want relatively painlessly..

    foreach($form_meta["fields"] as $field)
    {
    	 //handling single-input fields
    	$value = $_POST["input_" . $field["id"]];
    
    	//based on the label set the session field.
    	if($field["label"] == "First Name"){ $_SESSION["userFirstName"] = $value;}
    	if($field["label"] == "Last Name"){$_SESSION["userLastName"] = $value;}
    	if($field["label"] == "Email"){$_SESSION["userEmail"] = $value;}
    }
    Posted 14 years ago on Friday November 26, 2010 | Permalink
  5. cool, glad you found a fix. Be sure to check it works in all major browsers...I know some have issues with iframes - especially mobile devices

    Posted 14 years ago on Friday November 26, 2010 | Permalink