Hi Guys, I'm trying to update form parameters using hyperscript and listening to htmx:configRequest but I'm not able to make it work.
Is there something very obvious that I'm missing 😅
other events like input was working (paired with log)
I tried bunch of other events and I'm checking BE logs, htmx.logAll() + offline in network tab of browser devtools etc) to see if it works
for eg
[:input#amount.mt-1.block.w-full.rounded-md.border.border-gray-300.py-2.px-3.shadow-sm.focus:border-blue-500.focus:outline-none.focus:ring-1.focus:ring-blue-500
{:type "number"
:name "amount"
:required true
:step "0.1"
:_ "on htmx:trigger
log 'Form submitting...'
"
:placeholder "Enter amount in ₹"}]hm, I haven't used https://htmx.org/events/#htmx:configRequest before but it seems like that ought to do what you want. Let me try it...
maybe your problem is you need to put the hyperscript handler on the form element, not the input element
This snippet works for me:
[:form
{:hx-post "/test-config-request"
:_ "on htmx:configRequest set event.detail.parameters.auth_token to 'abc123'"}
[:input
{:type "number"
:name "amount"
:required true
:step "0.1"
:placeholder "Enter amount in ₹"}]
[:button {:type "submit"} "submit"]]
I had to put the :_ on the form element, and I also had to use :hx-post on the :form instead of a plain :action which seems obvious in hindsight but was something I missed initially.doing that, I'm able to see auth_token in the request params in the network tab: