fields.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. {{define "checkbox"}}
  2. <div class="form-check">
  3. <input type="checkbox" class="form-check-input" id="{{.Name}}" name="{{.Name}}"{{if .Required}} required{{end}}{{if .Checked}} checked{{end}}>
  4. {{if .Label}} <label class="form-check-label" for="{{.Name}}">{{.Label}}</label>{{end}}
  5. </div>
  6. {{if .Help}} <div id="{{.Name}}Help" class="form-text">{{.Help}}</div>{{end}}
  7. {{if .Error}}{{range $e := .Error}}<div class="text-danger">{{$e}}</div>{{end}}{{end}}
  8. {{end}}
  9. {{define "password"}}
  10. {{if .Label}}<label class="form-label" for="{{.Name}}">{{.Label}}</label>{{end}}
  11. <input type="password" id="{{.Name}}" name="{{.Name}}" class="form-control"
  12. {{- if .Placeholder}} placeholder="{{.Placeholder}}"{{end}}
  13. {{- if .Help}} aria-describedby="{{.Name}}Help"{{end}}
  14. {{- if .Required}} required{{end}}
  15. {{- if .AutoFocus}} autofocus{{end}}>
  16. {{if .Help}}<div id="{{.Name}}Help" class="form-text">{{.Help}}</div>{{end}}
  17. {{if .Error}}{{range $e := .Error}}<div class="text-danger">{{$e}}</div>{{end}}{{end}}
  18. {{end}}
  19. {{define "text"}}
  20. {{if .Label}}<label class="form-label" for="{{.Name}}">{{.Label}}</label>{{end}}
  21. <input type="text" id="{{.Name}}" name="{{.Name}}" class="form-control"
  22. {{- if .Value}} value="{{.Value}}"{{end}}
  23. {{- if .Placeholder}} placeholder="{{.Placeholder}}"{{end}}
  24. {{- if .Help}} aria-describedby="{{.Name}}Help"{{end}}
  25. {{- if .AutoComplete}} autocomplete="{{.AutoComplete}}"{{end}}
  26. {{- if .Required}} required{{end}}
  27. {{- if .AutoFocus}} autofocus{{end}}>
  28. {{if .Help}}<div id="{{.Name}}Help" class="form-text">{{.Help}}</div>{{end}}
  29. {{if .Error}}{{range $e := .Error}}<div class="text-danger">{{$e}}</div>{{end}}{{end}}
  30. {{end}}
  31. {{define "hidden"}}
  32. <input type="hidden" id="{{.Name}}" name="{{.Name}}" value="{{.Value}}">
  33. {{end}}