Skip to content

Commit

Permalink
Added radio form element example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestefanello committed May 18, 2024
1 parent 0e20442 commit 30389de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/routes/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions templates/pages/contact.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 30389de

Please sign in to comment.