Skip to content

Commit 2748bcb

Browse files
authored
gw-force-default-value.php: Added compatibility for date and time fields with force default value snippet.
1 parent 177fa3c commit 2748bcb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gravity-forms/gw-force-default-value.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ public function add_default_values_to_entry( $entry, $form ) {
8080
continue;
8181
}
8282

83-
$value = GFCommon::replace_variables( $value, $form, $entry );
83+
$value = is_string( $value ) ? GFCommon::replace_variables( $value, $form, $entry ) : $value;
8484

8585
if ( $value != $entry_value ) {
8686
$requires_update = true;
87+
// For array based values like Date Field and Time Field.
88+
if ( is_array( $value ) ) {
89+
$value = $field->get_value_save_entry( $value, $form, null, null, null );
90+
}
8791
$entry[ $field->id ] = $value;
8892
}
8993
}
@@ -109,7 +113,7 @@ public function replace_unreplaced_merge_tags( $text ) {
109113
return $text;
110114
}
111115
$chars = str_split( trim( $text ) );
112-
if ( $chars[0] === '{' && $chars[ count( $chars ) - 1 ] === '}' ) {
116+
if ( rgar( $chars, 0 ) === '{' && rgar( $chars, count( $chars ) - 1 ) === '}' ) {
113117
$text = '';
114118
}
115119
return $text;

0 commit comments

Comments
 (0)