htmx
htmx copied to clipboard
hx-val array handling
Currently, if I try to add an object containing an array on the first level to hx-val, the value is discarded and not added to the parameters of the call.
Example:
{
"firstLevel": [1,2,3],
"secondLevel": {
"values": [4,5,6]
}
}
Here, it fails due to the firstLevel field ("Multiple values for one key: "firstLevel""))
The secondLevel field would be accepted, as the whole objects gets passed as JSON.
Maybe arrays could be interpreted the same way as objects are.
I know this is old but I ran into a similar problem so I thought I would post my solution here for future people. You could make this work by putting hx-vals into a js object: https://htmx.org/attributes/hx-vals/