Skip to content

Commit 4ec83d7

Browse files
committed
fix selectize with keys
Signed-off-by: Andy Miller <rhuk@mac.com>
1 parent d2daf94 commit 4ec83d7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

system/src/Grav/Common/Data/Validation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,14 +813,19 @@ public static function typeArray($value, array $params, array $field)
813813
$options = $field['options'] ?? [];
814814
$use = $field['use'] ?? 'values';
815815

816+
// When `selectize.store_keys: true`, the form submits option keys rather
817+
// than option labels (the legacy default), so validate against keys.
818+
$selectizeStoreKeys = is_array($field['selectize'] ?? null)
819+
&& !empty($field['selectize']['store_keys']);
820+
816821
if ($validateOptions) {
817822
// Use custom options structure.
818823
foreach ($options as &$option) {
819824
$option = $option[$validateOptions] ?? null;
820825
}
821826
unset($option);
822827
$options = array_values($options);
823-
} elseif (empty($field['selectize']) || empty($field['multiple'])) {
828+
} elseif (empty($field['selectize']) || empty($field['multiple']) || $selectizeStoreKeys) {
824829
$options = array_keys($options);
825830
}
826831
if ($use === 'keys') {

0 commit comments

Comments
 (0)