Added radio form element example.

This commit is contained in:
mikestefanello 2024-05-18 16:19:27 -04:00
parent 0e204428b6
commit 30389de16f
2 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,7 @@ type (
contactForm struct {
Email string `form:"email" validate:"required,email"`
Department string `form:"department" validate:"required,oneof=sales marketing hr"`
Message string `form:"message" validate:"required"`
Submission controller.FormSubmission
}

View File

@ -31,6 +31,23 @@
{{template "field-errors" (.Form.Submission.GetFieldErrors "Email")}}
</div>
<div class="control">
<label class="label">Department</label>
<label class="radio">
<input type="radio" name="department" value="sales" {{if eq .Form.Department "sales"}}checked{{end}}/>
Sales
</label>
<label class="radio">
<input type="radio" name="department" value="marketing" {{if eq .Form.Department "marketing"}}checked{{end}}/>
Marketing
</label>
<label class="radio">
<input type="radio" name="department" value="hr" {{if eq .Form.Department "hr"}}checked{{end}}/>
HR
</label>
{{template "field-errors" (.Form.Submission.GetFieldErrors "Department")}}
</div>
<div class="field">
<label for="message" class="label">Message</label>
<div class="control">