File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 8
8
* Use this snippet to copy the label instead of the value.
9
9
*
10
10
* Instructions:
11
- * 1. Install our free Custom Javascript for Gravity Forms plugin.
11
+ * 1. Install our free Custom Javascript for Gravity Forms plugin.
12
12
* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/
13
13
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
14
14
*/
15
15
gform . 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 ( ' ' ) ;
21
29
}
22
- return value ;
30
+ return value ;
23
31
} ) ;
You can’t perform that action at this time.
0 commit comments