24 lines
1.1 KiB
Plaintext
24 lines
1.1 KiB
Plaintext
{{ define "input-field" -}}
|
|
{{- /*gotype: dev.tandem.ws/tandem/tipus/pkg/form.InputField*/ -}}
|
|
<div class="input{{ if .Errors }} has-errors{{ end }}"{{ if .Is }} is="{{ .Is }}"{{ end }}>
|
|
{{ if eq .Type "textarea" }}
|
|
<textarea name="{{ .Name }}" id="{{ .Name }}-field"
|
|
{{- range $attribute := .Attributes }} {{$attribute}} {{ end }}
|
|
{{ if .Required }}required="required"{{ end }} placeholder="{{ .Label }}"
|
|
>{{ .Val }}</textarea>
|
|
{{ else }}
|
|
<input type="{{ .Type }}" name="{{ .Name }}" id="{{ .Name }}-field"
|
|
{{- range $attribute := .Attributes }} {{$attribute}} {{ end }}
|
|
{{ if .Required }}required="required"{{ end }} value="{{ .Val }}" placeholder="{{ .Label }}">
|
|
{{ end }}
|
|
<label for="{{ .Name }}-field">{{ .Label }}</label>
|
|
{{- if .Errors }}
|
|
<ul>
|
|
{{- range $error := .Errors }}
|
|
<li>{{ . }}</li>
|
|
{{- end }}
|
|
</ul>
|
|
{{- end }}
|
|
</div>
|
|
{{- end }}
|