2023-04-18 09:23:18 +00:00
|
|
|
package clicktoedit
|
|
|
|
|
|
|
|
import "examples/shared"
|
|
|
|
|
|
|
|
templ Display(u user) {
|
|
|
|
<div hx-target="this" hx-swap="outerHTML">
|
|
|
|
<div><label>First Name</label>: { u.firstName }</div>
|
|
|
|
<div><label>Last Name</label>: { u.lastName }</div>
|
|
|
|
<div><label>Email</label>: { u.email }</div>
|
|
|
|
<button hx-get="/click-to-edit/contact/1/edit" class="button is-black">Click To Edit</button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ Form(u user) {
|
|
|
|
<form hx-put="/click-to-edit/contact/1" hx-target="this" hx-swap="outerHTML">
|
|
|
|
<div class="field">
|
|
|
|
<div class="control"><label>First Name</label><input class="input" type="text" name="firstName" value={ u.firstName }/></div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<div class="control"><label>Last Name</label><input class="input" type="text" name="lastName" value={ u.lastName }/></div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<div class="control"><label>Email Address</label><input class="input" type="email" name="email" value={ u.email }/></div>
|
|
|
|
</div>
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control"><button class="button is-black">Submit</button></div>
|
2023-05-02 13:52:29 +00:00
|
|
|
<div class="control"><button class="button" hx-get="/click-to-edit">Cancel</button></div>
|
2023-04-18 09:23:18 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
|
|
|
|
templ Index(u user) {
|
|
|
|
@shared.Layout("Click to Edit") {
|
|
|
|
<h2 class="title">Click to Edit</h2>
|
|
|
|
@Display(u)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|