Skip to content

Commit 7808a1c

Browse files
authored
gpcc-copy-to-conditionally-hidden-fields.php: Fixed an issue with copying to Multi Choice field.
1 parent a77bf8e commit 7808a1c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

gp-copy-cat/gpcc-copy-to-conditionally-hidden-fields.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@
4747
}
4848
}
4949

50-
if ( is_array( $source_values ) ) {
51-
foreach ( $source_values as $input_id => $source_value ) {
52-
$target_input_id = str_replace( "{$source_field->id}.", "{$target['target']}.", $input_id );
53-
$entry[ $target_input_id ] = $source_value;
50+
$values = is_array( $source_values ) ? array_values( $source_values ) : [ $source_values ];
51+
52+
foreach ( $values as $index => $value ) {
53+
$target_input_id = is_array( $source_values ) ? "{$target['target']}." . ( $index + 1 ) : $target['target'];
54+
$entry[ $target_input_id ] = $value;
55+
if ( ! is_array( $source_values ) ) {
56+
break;
5457
}
55-
} else {
56-
$entry[ $target['target'] ] = $source_values;
5758
}
5859
}
5960
}

0 commit comments

Comments
 (0)