bblanchon / django-htmx-modal-form

Django+HTMX modal form
99 stars 27 forks source link

Form validation error #2

Closed misosec closed 2 years ago

misosec commented 2 years ago

Hello, if I have <form method="POST">, form is submited fine, but if I have <form hx-post="{{ request.path }}"> form validation fails even I fill required form field (drop down)? If I set all field optional, form is submited with defaul values even I filled all fields manually.

What could be the issue here?

Thank you.

misosec commented 2 years ago

If I put hx-post={{ request.path }} into Save button and it worked. :-) Any idea why?

Thank you.

bblanchon commented 2 years ago

Hi @misosec,

As far as I can tell hx-post should go to the <form> tag. Do you have this problem with the (unchanged) code from this repository or some other code?

Best regards, Benoit

misosec commented 2 years ago

Hello @bblanchon ,

your code works fine for me. Any harm to leave it in <button> instead of <form>?

Thanks.

bblanchon commented 2 years ago

I'm afraid the hx-post will only trigger when the user clicks on the button, but not when she presses Enter while editing a field.

misosec commented 2 years ago

I'm afraid the hx-post will only trigger when the user clicks on the button, but not when she presses Enter while editing a field.

I see. I can live with that for now I guess and I will investigate later what I screwed up. :-)

Thanks again.