File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 88* Use this snippet to copy the label instead of the value.
99*
1010* Instructions:
11- * 1. Install our free Custom Javascript for Gravity Forms plugin.
11+ * 1. Install our free Custom Javascript for Gravity Forms plugin.
1212* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/
1313* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
1414*/
1515gform . addFilter ( 'gppc_copied_value' , function ( value , $elem , data ) {
16- $source = jQuery ( '#input_' + data . sourceFormId + '_' + data . source ) ;
17- if ( $source . is ( 'select' ) ) {
18- value = $source . find ( 'option:selected' ) . text ( ) ;
19- } else if ( $source . is ( '.gfield_radio' ) ) {
20- value = $ ( '.gfield-choice-input:checked + label' ) . text ( ) ;
16+ $source = jQuery ( '#input_' + data . sourceFormId + '_' + data . source ) ;
17+ if ( $source . is ( 'select' ) ) {
18+ value = $source . find ( 'option:selected' ) . text ( ) ;
19+ } else if ( $source . is ( '.gfield_radio' ) ) {
20+ value = $ ( '.gfield-choice-input:checked + label' ) . text ( ) ;
21+ } else if ( $source . is ( '.gfield_checkbox' ) ) {
22+ $inputs = $source . find ( 'input:checked' ) ;
23+ var checkedLabels = [ ] ;
24+ $inputs . each ( function ( ) {
25+ var label = $ ( this ) . next ( 'label' ) . text ( ) ;
26+ checkedLabels . push ( label ) ;
27+ } ) ;
28+ value = checkedLabels . join ( ' ' ) ;
2129 }
22- return value ;
30+ return value ;
2331} ) ;
You can’t perform that action at this time.
0 commit comments