Skip to content

Commit 688a57a

Browse files
authored
Components Bug: Cast key select and multi-select IDs to string (#2690)
* check for null/is_array * Cast multi-select IDs to string A field with integer keys for a multi-select was causing a failure saving a new/existing multi-select button group value. * Fix for key select as well
1 parent d039e54 commit 688a57a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

dt-core/utilities/dt-components.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static function render_key_select( $field_key, $fields, $post, $params =
129129

130130
$options = array_map(function ( $key, $value ) use ( $params ) {
131131
$option = [
132-
'id' => $key,
132+
'id' => (string) $key,
133133
'label' => $value['label'],
134134
];
135135
if ( !isset( $params['key_select']['disable_color'] ) ) {
@@ -163,7 +163,7 @@ public static function render_multi_select( $field_key, $fields, $post, $params
163163
$options_array = $fields[$field_key]['default'];
164164
$options_array = array_map(function ( $key, $value ) {
165165
return [
166-
'id' => $key,
166+
'id' => (string) $key,
167167
'label' => $value['label'] ?? $key,
168168
'color' => $value['color'] ?? null,
169169
'icon' => $value['icon'] ?? null,

0 commit comments

Comments
 (0)