Files
spring-boot-demo/thymeleaf-htmx/output/07-inline-edit.txt
T

64 lines
2.0 KiB
Plaintext

# request (curl notation, sent through MockMvc): curl -H 'HX-Request: true' /contacts/1/edit (Edit button)
HTTP 200
---- body (523 chars) ----
<tr id="contact-1" class="editing">
<td>
<input name="name" value="Aarav Kulkarni">
</td>
<td>
<input name="email" value="[email protected]">
</td>
<td>
<input name="role" value="Developer">
</td>
<td>
<button type="button"
hx-include="closest tr" hx-target="closest tr" hx-swap="outerHTML" hx-put="/contacts/1">Save</button>
<button type="button"
hx-target="closest tr" hx-swap="outerHTML" hx-get="/contacts/1">Cancel</button>
</td>
</tr>
# request (curl notation, sent through MockMvc): curl -X PUT -H 'HX-Request: true' -d 'name=&email=broken&role=Architect' /contacts/1 (Save, invalid)
HTTP 422
---- body (625 chars) ----
<tr id="contact-1" class="editing">
<td>
<input name="name" value="" class="invalid">
<small class="error">Name is required</small>
</td>
<td>
<input name="email" value="broken" class="invalid">
<small class="error">Email must look like name@host</small>
</td>
<td>
<input name="role" value="Architect">
</td>
<td>
<button type="button"
hx-include="closest tr" hx-target="closest tr" hx-swap="outerHTML" hx-put="/contacts/1">Save</button>
<button type="button"
hx-target="closest tr" hx-swap="outerHTML" hx-get="/contacts/1">Cancel</button>
</td>
</tr>
# request (curl notation, sent through MockMvc): curl -X PUT -H 'HX-Request: true' -d 'name=Aarav K.&[email protected]&role=Architect' /contacts/1 (Save, valid)
HTTP 200
---- body (382 chars) ----
<tr id="contact-1">
<td>Aarav K.</td>
<td>[email protected]</td>
<td>Architect</td>
<td>
<button type="button"
hx-target="closest tr" hx-swap="outerHTML" hx-get="/contacts/1/edit">Edit</button>
<button type="button"
hx-target="closest tr" hx-swap="outerHTML" hx-delete="/contacts/1" hx-confirm="Delete Aarav K.?">Delete</button>
</td>
</tr>