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.

Saving multiple input fields generated via gform_field_input hook

  1. Hi,

    I'm having a function generate a number of input fields to overwrite a "Single Line Text" input field, which has a CSS class "subsection":

    add_filter( 'gform_field_input', 'gform_cart_subsection', 10, 5);
    
    function gform_cart_subsection($input, $field, $value, $lead_id, $form_id){
        if($field["cssClass"] == "subsection"){
    
            $favs = // array including post ID's added to favorites, stored in a cookie ;
    
    		foreach ( array_keys ($favs) as $fav){
    			$input .= '<label for="fav' . $fav . '">' . get_the_title($fav) . '</label><input name="field_1_9" id="fav' . $fav . '" type="text" value="Add a note..."><br/>';
    		}
        }
        return $input;
    }

    The form shows up fine on the front-end, but after submission, the content of the input fields generated do not show up in the Entry on the back-end.

    I've tried json encoding as recommended by this post:
    http://www.gravityhelp.com/forums/topic/cant-submit-input-name-array-to-show-up-in-entry-list
    to no avail. What do you have to do after creating a "custom input" in order to save the submission?

    Thanks,

    Sepehr

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  2. I'll ask the development team about this one for you.

    Posted 11 years ago on Monday February 4, 2013 | Permalink
  3. I heard back from one of the developers today:

    Gravity Forms relies on the input's name attribute to save entries, so you have two problems:

    1. You have hard-coded the input name (ie. name="field_1_9"). These need to be named in the format: "input_FORMID_FIELDID"
    2. You have multiple inputs associated with one field, so the easiest thing to do is to create a single hidden input, named following the GF naming convention (i.e. input_FORMID_FIELDID), and then use Javascript to populate this hidden input when the other input fields change.

    Also, I think it will make more sense to use a single column list field instead, and then use gform_field_value_$parameter_name to populate the list field.

    http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name

    This will likely work much better for you. If you need additional help, please let us know.

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  4. Chris, thanks much for the tip, I'll try the the list field.

    Posted 11 years ago on Thursday February 7, 2013 | Permalink
  5. Let us know if you need more help.

    Posted 11 years ago on Thursday February 7, 2013 | Permalink