shelves/templates/tmpls/form.tmpl.html
2024-11-15 15:25:29 -05:00

35 lines
652 B
HTML

{{define "attrs"}}
name="{{.Name}}"
placeholder="{{.Placeholder}}"
aria-invalid="{{not .Valid}}"
{{if .Error}}
aria-describedby="{{.Name}}-error"
{{end}}
{{end}}
<form action="{{.Action}}" method="{{.Method}}">
{{range .Fields}}
<mu-field>
<label>
{{.Label}}
{{if eq .Type "textarea"}}
<textarea
{{template "attrs" .}}
>{{.Value}}</textarea>
{{else}}
<input
type="{{.Type}}"
value="{{.Value}}"
{{template "attrs" .}}
>
{{end}}
</label>
{{if .Error}}
<small id="{{.Name}}-error">{{.Error}}</small>
{{end}}
</mu-field>
{{end}}
<input type="submit" value="Submit">
</form>