summaryrefslogtreecommitdiff
path: root/templ/form.tpl
blob: 4d20557a8dd51602702afeb9dcec92b6cd03732d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{{define "formItem"}}
    {{- $cb := eq .Type "checkbox" -}}
    <div class="{{if $cb}}form-check form-switch{{else}}form-floating{{end}} mb-3">
        <input
            {{with .ID}}id="{{.}}"{{end}}
            type="{{.Type}}"
            name="{{.Name}}"
            placeholder="{{.Placeholder}}"
            {{with .Value}}value="{{.}}"{{end}}
            {{with .Class}}class="{{.}}"{{end}}
            class="{{if $cb}}form-check-input{{else}}form-control{{end}}"
            {{range .Options}} {{.}} {{end}}
        >
    <label {{with .ID}}for="{{.}}"{{end}}
           {{- if $cb}}class="form-check-label"{{end}}>{{.Label}}</label>

    {{range errors}}
        <p style="color:red">{{.}}</p>
    {{end}}
    {{with .Footer}}<p>{{.}}</p>{{end}}
    </div>
{{end}}