saasitone/templ/pages/register.templ

58 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2024-07-14 18:48:40 -07:00
package pages
import (
"git.grosinger.net/tgrosinger/saasitone/templ/components"
"git.grosinger.net/tgrosinger/saasitone/pkg/form"
"git.grosinger.net/tgrosinger/saasitone/pkg/page"
)
type RegisterForm struct {
Name string `form:"name" validate:"required"`
Email string `form:"email" validate:"required,email"`
Password string `form:"password" validate:"required"`
ConfirmPassword string `form:"password-confirm" validate:"required,eqfield=Password"`
form.Submission
}
templ Register(p page.Page, f *RegisterForm) {
<form method="post" hx-boost="true" action={ templ.URL(p.ToURL("register.submit")) }>
<div class="field">
<label for="name" class="label">Name</label>
<div class="control">
<input type="text" id="name" name="name" class={ "input", f.Submission.GetFieldStatusClass("Name") } value={ f.Name }/>
@components.FieldErrors(f.Submission.GetFieldErrors("Name"))
</div>
</div>
<div class="field">
<label for="email" class="label">Email address</label>
<div class="control">
<input type="email" id="email" name="email" class={ "input", f.Submission.GetFieldStatusClass("Email") } value={ f.Email }/>
@components.FieldErrors(f.Submission.GetFieldErrors("Email"))
</div>
</div>
<div class="field">
<label for="password" class="label">Password</label>
<div class="control">
<input type="password" id="password" name="password" placeholder="*******" class={ "input", f.Submission.GetFieldStatusClass("Password") }/>
@components.FieldErrors(f.Submission.GetFieldErrors("Password"))
</div>
</div>
<div class="field">
<label for="password-confirm" class="label">Confirm password</label>
<div class="control">
<input type="password" id="password-confirm" name="password-confirm" placeholder="*******" class={ "input", f.Submission.GetFieldStatusClass("ConfigmPassword") }/>
@components.FieldErrors(f.Submission.GetFieldErrors("ConfigmPassword"))
</div>
</div>
<div class="field is-grouped">
<p class="control">
<button class="button is-primary">Register</button>
</p>
<p class="control">
<a href={ templ.URL(p.ToURL("home")) } class="button is-light">Cancel</a>
</p>
</div>
@components.CSRF(p.CSRF)
</form>
}