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 #1141)
This commit is contained in:
parent
0ba0833f67
commit
57522dc3ff
2 changed files with 9 additions and 1 deletions
web-frontend
|
@ -4,7 +4,11 @@ export function getPrefills(query) {
|
||||||
const keyFormatted = key
|
const keyFormatted = key
|
||||||
.replace('prefill_', '') // Remove the prefix
|
.replace('prefill_', '') // Remove the prefix
|
||||||
.replaceAll('+', ' ') // Replace + with spaces
|
.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
|
return prefills
|
||||||
}, Object.create(null))
|
}, Object.create(null))
|
||||||
|
|
|
@ -17,6 +17,10 @@ const valuesToCall = [
|
||||||
query: { 'prefill_value+with+spaces': 'value' },
|
query: { 'prefill_value+with+spaces': 'value' },
|
||||||
result: { 'value with spaces': 'value' },
|
result: { 'value with spaces': 'value' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
query: { prefill_value: ['value', 'value_2'] },
|
||||||
|
result: { value: 'value_2' },
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
describe('Form utils test', () => {
|
describe('Form utils test', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue