Copy as Comma-delimited List

When copying multiple values to a single input, Copy Cat will join

Instructions

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

  2. Configure the snippet per the inline instructions.

Code

Filename: gpcc-copy-as-comma-delimited-list.js

/**
* Gravity Perks // Copy Cat // Copy as Comma-delimited List
* https://gravitywiz.com/documentation/gravity-forms-copy-cat/
*
* When copying multiple values to a single input, Copy Cat will join
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
*    https://gravitywiz.com/gravity-forms-code-chest/
*
* 2. Configure the snippet per the inline instructions.
*/
gform.addFilter( 'gppc_copied_value', function( value, $elem, data, sourceValues ) {
	// Update "4" to ID of the field that should be populated with commma-delimited values.
	if ( data.target == 4 ) {
		value = sourceValues.join( ', ' );
	}
	return value;
} );

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.