Skip to content

Commit

Permalink
dependent_fields_frame: make it also work with select-multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
pascallaliberte committed Nov 16, 2024
1 parent e0123ad commit 9b4a064
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,12 @@ export default class extends Controller {
const form = field.form
const formData = form ? new FormData(form) : {}

if (field.type === "checkbox" && field.name.endsWith("[]")) {
// Remove any existing values for this field
if ((field.type === "checkbox" || field.type === "select-multiple") && field.name.endsWith("[]")) {
url.searchParams.delete(field.name)

// Add all values from formData for this field
formData.getAll(field.name).forEach(value => {
url.searchParams.append(field.name, value)
})
} else {
// Handle single value fields
url.searchParams.set(field.name, this.getValueForField(field))
}

Expand Down

0 comments on commit 9b4a064

Please sign in to comment.