fix: host modal — single POST endpoint for create+edit, remove hx-put conflict

- hx-put="" (empty) was causing HTMX to send wrong requests
- Now use single hx-post="/hosts" with hidden hostId field
- Server checks hostId: empty → create, present → update
- UpdateHost reads ID from both URL param and form data
This commit is contained in:
swanadiva
2026-07-07 15:56:54 +07:00
parent 301115b74d
commit a2412b7cd2
2 changed files with 12 additions and 4 deletions
+2 -2
View File
@@ -15,11 +15,11 @@
</button>
</div>
<form :hx-post="editing ? null : '/hosts'"
:hx-put="editing ? '/hosts/' + hostId : null"
<form hx-post="/hosts"
hx-target="#host-list" hx-swap="innerHTML"
@submit="open = false; $dispatch('toast-message', { message: editing ? 'Host updated' : 'Host added' })"
class="p-6 space-y-4 text-sm">
<input type="hidden" name="hostId" :value="editing ? hostId : ''">
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-1.5">