Skip to content

Commit

Permalink
fix list choice field not working b/c of incorrect value attribute. r…
Browse files Browse the repository at this point in the history
…elates to a20265a
  • Loading branch information
dannyvankooten committed Jun 7, 2023
1 parent 782a6da commit f7e731a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions assets/src/js/admin/form-editor/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ function FieldChoice (data) {
}

function createChoices (data) {
return Object.keys(data).map((key) => {
const fc = { label: data[key] }
if (typeof (key) === 'number' && isFinite(key)) {
fc.value = key
}

return new FieldChoice(fc)
})
// Here we create FieldChoice object for each choice item
// If we got an associate array / dictionary / object then we use keys as values
// Otherwise, we leave it to the rendering phase to set the value attribute
return Object.keys(data).map((key) => new FieldChoice({ label: data[key], value: Array.isArray(data) ? null : key }))
}

function register (category, data) {
Expand Down

0 comments on commit f7e731a

Please sign in to comment.