Copy Comma-delimited Value to Checkbox Field

Use Copy Cat to check the checkboxes in a Checkbox field based on a comma-delimited value from a single-value field (like a Single Line Text field).

Instructions

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

Code

Filename: gpcc-copy-comma-delimited-value-to-checkbox.js

/**
 * Gravity Perks // Copy Cat // Copy Comma-delimited Value to Checkbox Field
 * https://gravitywiz.com/documentation/gravity-forms-copy-cat/
 *
 * Use Copy Cat to check the checkboxes in a Checkbox field based on a comma-delimited value
 * from a single-value field (like a Single Line Text field).
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
gform.addFilter( 'gpcc_copied_value', function( sourceValues, $targetElem, field ) {
  // Update "3" to your Checkbox field ID.
	if ( field.target == 3 ) {
		sourceValues = sourceValues[0].split( ', ' );
	}
	return sourceValues;
} );

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.