Skip to content

Commit

Permalink
Properly serialize fields with multiple values (#3067)
Browse files Browse the repository at this point in the history
Co-authored-by: Steffen Deusch <steffen.deusch@teaminternet.com>
  • Loading branch information
SteffenDE and Steffen Deusch authored Jan 31, 2024
1 parent e31f634 commit 666b4d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ let serializeForm = (form, metadata, onlyNames = []) => {
// to check if the current element value exists in the form data.
Array.from(form.elements).forEach(el => {
if(el.name && onlyNames.length === 0 || onlyNames.indexOf(el.name) >= 0){
if((el.name && formData.getAll(el.name).indexOf(el.value) >= 0) || submitter === el){
params.append(el.name, el.value)
const values = formData.getAll(el.name)
if((el.name && values.indexOf(el.value) >= 0) || submitter === el){
values.forEach(val => params.append(el.name, val))
}
}
})
Expand Down

0 comments on commit 666b4d1

Please sign in to comment.