fix(dropdown-multiple): a valid option starting by [ may not be a JSON value

This commit is contained in:
Colin Darie 2024-02-20 17:41:53 +01:00
parent da19ba5fe4
commit 560d50f52d
2 changed files with 4 additions and 2 deletions

View file

@ -90,7 +90,7 @@ class Champs::MultipleDropDownListChamp < Champ
values = if value.is_a?(Array)
value
elsif value.starts_with?('[')
JSON.parse(value)
JSON.parse(value) rescue selected_options + [value] # value may start by [ without being a real JSON value
else
selected_options + [value]
end.uniq.without('')