Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,20 @@ public static function array_flatten( $array, $keys = 'keep' ) {
return $return;
}

/**
* Flatten an array before imploding it to avoid Array to string conversion warnings.
*
* @since x.x
*
* @param string $sep
* @param array $array
* @return string
*/
public static function safe_implode( $sep, $array ) {
$array = self::array_flatten( $array );
return implode( $sep, $array );
}
Comment thread
Crabcyborg marked this conversation as resolved.

/**
* @param string $text
* @param bool $is_rich_text
Expand Down
2 changes: 1 addition & 1 deletion classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ private static function get_field_shortcode_value( $atts ) {
$string_value = $replace_with;
if ( is_array( $replace_with ) ) {
$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
$string_value = implode( $sep, $replace_with );
$string_value = FrmAppHelper::safe_implode( $sep, $replace_with );
Comment thread
Crabcyborg marked this conversation as resolved.
}

if ( empty( $string_value ) && $string_value != '0' ) {
Expand Down
6 changes: 3 additions & 3 deletions classes/models/fields/FrmFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,11 +1440,11 @@ public function get_display_value( $value, $atts = array() ) {
$value = $this->prepare_display_value( $value, $atts );

if ( is_array( $value ) ) {
if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[ $atts['show'] ] ) ) {
if ( ! empty( $atts['show'] ) && isset( $value[ $atts['show'] ] ) ) {
$value = $value[ $atts['show'] ];
} elseif ( ! isset( $atts['return_array'] ) || ! $atts['return_array'] ) {
} elseif ( empty( $atts['return_array'] ) ) {
$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
$value = implode( $sep, $value );
$value = FrmAppHelper::safe_implode( $sep, $value );
}
}

Expand Down