forked from goffee/core
Merge pull request 'template with select multiple, input custom attribute' (#22) from jacs/core:develop into develop
Reviewed-on: goffee/core#22
This commit is contained in:
commit
5c3559c793
4 changed files with 13 additions and 1 deletions
|
|
@ -11,4 +11,10 @@ type FormInput struct {
|
||||||
IsDisabled bool
|
IsDisabled bool
|
||||||
Autocomplete bool
|
Autocomplete bool
|
||||||
IsRequired bool
|
IsRequired bool
|
||||||
|
CustomAtt []CustomAtt
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomAtt struct {
|
||||||
|
AttName string
|
||||||
|
AttValue string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@
|
||||||
{{if ne .Value ""}}
|
{{if ne .Value ""}}
|
||||||
value="{{.Value}}"
|
value="{{.Value}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if .CustomAtt }}
|
||||||
|
{{range $options := .CustomAtt}}
|
||||||
|
{{$options.AttName}}="{{$options.AttValue}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
aria-describedby="{{.ID}}Help">
|
aria-describedby="{{.ID}}Help">
|
||||||
{{if ne .Hint ""}}<small id="{{.ID}}Help" class="form-text text-muted">{{.Hint}}</small>{{end}}
|
{{if ne .Hint ""}}<small id="{{.ID}}Help" class="form-text text-muted">{{.Hint}}</small>{{end}}
|
||||||
{{if ne .Error ""}}<div class="error">{{.Error}}</div>{{end}}
|
{{if ne .Error ""}}<div class="error">{{.Error}}</div>{{end}}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ type FormSelect struct {
|
||||||
SelectedOption FormSelectOption
|
SelectedOption FormSelectOption
|
||||||
Label string
|
Label string
|
||||||
AllOptions []FormSelectOption
|
AllOptions []FormSelectOption
|
||||||
|
IsMultiple bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type FormSelectOption struct {
|
type FormSelectOption struct {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{{define "form_select"}}
|
{{define "form_select"}}
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
<label for="{{.ID}}" class="form-label">{{.Label}}</label>
|
<label for="{{.ID}}" class="form-label">{{.Label}}</label>
|
||||||
<select class="form-select" id="{{.ID}}" name="{{.ID}}">
|
<select class="form-select" id="{{.ID}}" name="{{.ID}}"{{if eq .IsMultiple true}} multiple{{end}}>
|
||||||
{{range $options := .AllOptions}}
|
{{range $options := .AllOptions}}
|
||||||
<option value="{{$options.Value}}" {{if eq $options.Value $.SelectedOption.Value }}selected="selected"{{end}}>{{$options.Caption}}</option>
|
<option value="{{$options.Value}}" {{if eq $options.Value $.SelectedOption.Value }}selected="selected"{{end}}>{{$options.Caption}}</option>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue