Skip to content

Commit 7f45cfe

Browse files
committed
gw-merge-tag-modifier-sentence.php: Added support for Multi Selects.
1 parent 5d65335 commit 7f45cfe

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

gravity-forms/gw-merge-tag-modifier-sentence.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*
1111
* this: First Choice, Second Choice, Third Choice
1212
* to: First Choice, Second Choice, and Third Choice.
13-
*
14-
* This does not currently work in conjunction with the :value modifier as Gravity Forms does not support more than a single
15-
* modifier on Checkbox field merge tags. Also, this will not work if your choices contain a comma.
1613
*/
1714
add_filter( 'gform_merge_tag_filter', function( $value, $input_id, $modifier, $field, $raw_values, $format ) {
1815

@@ -25,7 +22,15 @@
2522
return $value;
2623
}
2724

28-
$values = array_filter( array_map( 'trim', $raw_values ) );
25+
$values = $raw_values;
26+
if ( $field->storageType === 'json' ) {
27+
$values = json_decode( $values );
28+
if ( ! is_array( $values ) ) {
29+
$values = array();
30+
}
31+
}
32+
33+
$values = array_filter( array_map( 'trim', $values ) );
2934
$count = count( $values );
3035

3136
if ( $count > 1 ) {

0 commit comments

Comments
 (0)