Copy Multiple Checkbox Fields to a List Field

Copy checked checkbox values from multiple Checkbox fields to a single List field. Screenshot.

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/

  2. Update snippet based on inline instructions.

Code

Filename: gpcc-copy-multiple-checkboxes-to-list-field.js

/**
 * Gravity Perks // Copy Cat // Copy Multiple Checkbox Fields to a List Field
 * https://gravitywiz.com/documentation/gravity-forms-copy-cat/
 *
 * Copy checked checkbox values from multiple Checkbox fields to a single List field.
 * [Screenshot](https://gwiz.io/3hhPeXH).
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 *
 * 2. Update snippet based on inline instructions.
 */
gform.addFilter( 'gpcc_field_group', function( $group, field, groupType, $field ) {
	// Update "3.1" to your List field ID and column number.
	if ( groupType !== 'source' || field.target !== '3.1' ) {
		return $group;
	}
	// Update "1" to your first Checkbox field ID and "2" to your second Checkbox field ID.
	$group = $( '#field_GFFORMID_1, #field_GFFORMID_2' ).find( 'input:checked' );
	return $group;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.