1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-28 14:32:26 +00:00

Fix crash on duplicate prefill of MultipleChoiceField (fixes )

This commit is contained in:
Gaurang Tandon 2022-08-10 06:26:21 +00:00 committed by Alexander Haller
parent 0ba0833f67
commit 57522dc3ff
2 changed files with 9 additions and 1 deletions
web-frontend
modules/database/utils
test/unit/database/utils

View file

@ -4,7 +4,11 @@ export function getPrefills(query) {
const keyFormatted = key
.replace('prefill_', '') // Remove the prefix
.replaceAll('+', ' ') // Replace + with spaces
prefills[keyFormatted] = query[key]
let valueChosen = query[key]
if (Array.isArray(query[key])) {
valueChosen = valueChosen[valueChosen.length - 1]
}
prefills[keyFormatted] = valueChosen
}
return prefills
}, Object.create(null))

View file

@ -17,6 +17,10 @@ const valuesToCall = [
query: { 'prefill_value+with+spaces': 'value' },
result: { 'value with spaces': 'value' },
},
{
query: { prefill_value: ['value', 'value_2'] },
result: { value: 'value_2' },
},
]
describe('Form utils test', () => {