List output shifting data to different columns [RESOLVED]

I’m using the multi-column list fields, and the output data shifts if the user leaves a field blank. How do I make empty fields return some sort of value to keep the columns in order? See attachment for output data screenshot. (PS, I covered names and zips codes in this screenshot; names are green boxes, zips are blue)

Hi Brittany,

I’m just a paying user like yourself, but I have played around a bit with List fields in a developer context, and I never noticed a similar anomaly as you describe in any of my own testing.

Can you describe a little more about the steps, components, and context for your process ?

Cheers

Are you running the latest version (2.4.10)? An issue like this was fixed in version 2.4.6.

Sure thing! I did add some functions to add masks to the fields. It’s very possible that it’s affecting/causing this:

   add_filter( 'gform_column_input_1_1_3', 'set_column3', 10, 5 );
    function set_column3( $input_info, $field, $column, $value, $form_id ) {
        return array( 'type' => 'select', 'choices' => 'M,F' );
    }

add_filter( 'gform_column_input_1_1_8', 'set_column8', 10, 5 );
function set_column8( $input_info, $field, $column, $value, $form_id ) {
    return array( 'type' => 'select', 'choices' => 'FT,PT,Contractor,Executive,COBRA' );
}


add_filter('gform_register_init_scripts_1', 'enable_list_input_mask');
function enable_list_input_mask($form) {
    $field_id = "1"; 
    $col_id = array('4','7'); 
    $mask = "99/99/9999"; 

    $c_sel = array();
    foreach($col_id as $c) {
        $c_sel[] = ".gfield_list_{$field_id}_cell{$c} input";
    }
    $c_sels = json_encode($c_sel);
    $im_script = "jQuery(sel.join()).mask('{$mask}');";
    $script = "var sel = {$c_sels}; {$im_script} jQuery('#field_{$form["id"]}_{$field_id}').on('click', '.add_list_item', function(){{$im_script}});";
    GFFormDisplay::add_init_script($form['id'], 'list_input_mask', GFFormDisplay::ON_PAGE_RENDER, $script);
    return $form;
}
add_action( 'gform_enqueue_scripts_1', 'list_masked_input_script', 10, 2 );
function list_masked_input_script( $form ) {
    wp_enqueue_script( 'gform_masked_input', array( 'jquery' ), false, true );
}

I’m running 2.4.9, but I’ll see if updating it to 2.4.10 does anything.

Hi again !

Before I dig too deep into your helpful context, may I suggest you try one thing first, as I’ve found this very helpful in the past myself…

Enable GF debug logging, and dump the in-bound data, as well as your own modified data into the log, and examine it closely. Sometimes this will help reveal where you might have malformed the returned function’s response.

$tmp = print_r( $someObjOrArray, TRUE );
GFCommon::log_debug(__METHOD__ . " Your DB MSG: info = $tmp ");

Let us know if this helps, or if you are still stuck.

Sorry for the super delayed response, but this is what I figured out - these seem to be the culprit:

add_filter( 'gform_column_input_1_1_3', 'set_column3', 10, 5 );
function set_column3( $input_info, $field, $column, $value, $form_id ) {
    return array( 'type' => 'select', 'choices' => 'M,F' );
}

add_filter( 'gform_column_input_1_1_8', 'set_column8', 10, 5 );
function set_column8( $input_info, $field, $column, $value, $form_id ) {
    return array( 'type' => 'select', 'choices' => 'FT,PT,Contractor,Executive,COBRA' );
}

When you get to row 3+ of the list, it starts duplicating the IDs of the elements, so the output returns empty values for these two dropdowns from row 3+.

1 Like

Figured out what the problem was, and it wasn’t Gravity Forms related. I’m using Pretty Dropdowns, and it didn’t seem to want to play nice with the dropdowns in the list items. It wasn’t throwing a console error, so I didn’t think to look at that at first. Thanks for your help regardless! :slight_smile:

1 Like

Glad to hear you solved it.

I’ve come to learn over the years, that the best way to solve problem issues begins with working thru every assumption you have, and verify them. Inevitably there will be discovered at least one assumption which was wrong, and was the root cause of your issue.

Cheers

1 Like
© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.