2023-01-31 14:40:12 +00:00
|
|
|
{{ define "input-field" -}}
|
|
|
|
<div class="input {{ if .Errors }}has-errors{{ end }}">
|
2023-02-07 14:28:22 +00:00
|
|
|
{{ if eq .Type "textarea" }}
|
2023-02-08 12:47:36 +00:00
|
|
|
<textarea name="{{ .Name }}" id="{{ .Name }}-field"
|
2023-02-07 14:28:22 +00:00
|
|
|
{{- range $attribute := .Attributes }} {{$attribute}} {{ end }}
|
2023-02-08 12:47:36 +00:00
|
|
|
{{ if .Required }}required="required"{{ end }} placeholder="{{ .Label }}"
|
|
|
|
>{{ .Val }}</textarea>
|
2023-02-07 14:28:22 +00:00
|
|
|
{{ else }}
|
|
|
|
<input type="{{ .Type }}" name="{{ .Name }}" id="{{ .Name }}-field"
|
|
|
|
{{- range $attribute := .Attributes }} {{$attribute}} {{ end }}
|
|
|
|
{{ if .Required }}required="required"{{ end }} value="{{ .Val }}" placeholder="{{ .Label }}">
|
|
|
|
{{ end }}
|
2023-01-31 14:40:12 +00:00
|
|
|
<label for="{{ .Name }}-field">{{ .Label }}</label>
|
2023-02-01 10:02:32 +00:00
|
|
|
{{- if .Errors }}
|
2023-01-31 14:40:12 +00:00
|
|
|
<ul>
|
|
|
|
{{- range $error := .Errors }}
|
|
|
|
<li>{{ . }}</li>
|
|
|
|
{{- end }}
|
|
|
|
</ul>
|
2023-02-01 10:02:32 +00:00
|
|
|
{{- end }}
|
2023-01-31 14:40:12 +00:00
|
|
|
</div>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "select-field" -}}
|
|
|
|
<div class="input {{ if .Errors }}has-errors{{ end }}">
|
2023-02-01 13:15:02 +00:00
|
|
|
<select id="{{ .Name }}-field" name="{{ .Name }}"
|
2023-02-05 13:06:33 +00:00
|
|
|
{{- range $attribute := .Attributes }} {{$attribute}} {{ end -}}
|
2023-02-08 12:47:36 +00:00
|
|
|
{{ if .Multiple }}multiple="multiple"{{ end }}
|
2023-02-05 13:06:33 +00:00
|
|
|
{{ if .Required }}required="required"{{ end }}
|
2023-02-01 13:15:02 +00:00
|
|
|
>
|
2023-02-05 13:06:33 +00:00
|
|
|
{{- with .EmptyLabel }}
|
|
|
|
<option value="">{{ . }}</option>
|
|
|
|
{{- end}}
|
|
|
|
{{- range $option := .Options }}
|
|
|
|
<option value="{{ .Value }}"
|
2023-02-08 12:47:36 +00:00
|
|
|
{{- if $.IsSelected .Value }} selected="selected"{{ end }}>{{ .Label }}</option>
|
2023-02-05 13:06:33 +00:00
|
|
|
{{- end }}
|
2023-01-31 14:40:12 +00:00
|
|
|
</select>
|
|
|
|
<label for="{{ .Name }}-field">{{ .Label }}</label>
|
2023-02-01 13:15:02 +00:00
|
|
|
{{- if .Errors }}
|
2023-01-31 14:40:12 +00:00
|
|
|
<ul>
|
|
|
|
{{- range $error := .Errors }}
|
|
|
|
<li>{{ . }}</li>
|
|
|
|
{{- end }}
|
|
|
|
</ul>
|
2023-02-01 13:15:02 +00:00
|
|
|
{{- end }}
|
2023-01-31 14:40:12 +00:00
|
|
|
</div>
|
|
|
|
{{- end }}
|