forked from goffee/core
develop #1
8 changed files with 87 additions and 0 deletions
14
template/components/form_checkbox.go
Normal file
14
template/components/form_checkbox.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package components
|
||||
|
||||
type FormCheckbox struct {
|
||||
Label string
|
||||
AllCheckbox []FormCheckboxItem
|
||||
}
|
||||
|
||||
type FormCheckboxItem struct {
|
||||
ID string
|
||||
Name string
|
||||
Value string
|
||||
Label string
|
||||
IsChecked bool
|
||||
}
|
11
template/components/form_checkbox.html
Normal file
11
template/components/form_checkbox.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{define "form_checkbox"}}
|
||||
<div class="input-container">
|
||||
<label class="form-label">{{.Label}}</label>
|
||||
{{range $options := .AllCheckbox}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="{{$options.Name}}" id="{{$options.ID}}" value="{{$options.Value}}"{{if eq $options.IsChecked true}} checked{{end}}>
|
||||
<label class="form-check-label" for="{{$options.ID}}">{{$options.Label}}</label>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
15
template/components/form_radio.go
Normal file
15
template/components/form_radio.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package components
|
||||
|
||||
type FormRadio struct {
|
||||
Label string
|
||||
AllRadios []FormRadioItem
|
||||
}
|
||||
|
||||
type FormRadioItem struct {
|
||||
ID string
|
||||
Name string
|
||||
Value string
|
||||
Label string
|
||||
IsDisabled bool
|
||||
IsChecked bool
|
||||
}
|
11
template/components/form_radio.html
Normal file
11
template/components/form_radio.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{define "form_radio"}}
|
||||
<div class="input-container">
|
||||
<label class="form-label">{{.Label}}</label>
|
||||
{{range $options := .AllRadios}}
|
||||
<div class="form-check{{if eq $options.IsDisabled true}} disabled{{end}}">
|
||||
<input class="form-check-input" type="radio" name="{{$options.Name}}" id="{{$options.ID}}" value="{{$options.Value}}"{{if eq $options.IsDisabled true}} disabled=""{{end}}{{if eq $options.IsChecked true}} checked=""{{end}}>
|
||||
<label class="form-check-label" for="{{$options.ID}}">{{$options.Label}}</label>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
13
template/components/form_select.go
Normal file
13
template/components/form_select.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package components
|
||||
|
||||
type FormSelect struct {
|
||||
ID string
|
||||
SelectedOption FormSelectOption
|
||||
Label string
|
||||
AllOptions []FormSelectOption
|
||||
}
|
||||
|
||||
type FormSelectOption struct {
|
||||
Value string
|
||||
Caption string
|
||||
}
|
10
template/components/form_select.html
Normal file
10
template/components/form_select.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{define "form_select"}}
|
||||
<div class="input-container">
|
||||
<label for="{{.ID}}" class="form-label">{{.Label}}</label>
|
||||
<select class="form-select" id="{{.ID}}" name="{{.ID}}">
|
||||
{{range $options := .AllOptions}}
|
||||
<option value="{{$options.Value}}" {{if eq $options.Value $.SelectedOption.Value }}selected="selected"{{end}}>{{$options.Caption}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
{{end}}
|
7
template/components/form_textarea.go
Normal file
7
template/components/form_textarea.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package components
|
||||
|
||||
type FormTextarea struct {
|
||||
ID string
|
||||
Label string
|
||||
AllOptions []FormSelectOption
|
||||
}
|
6
template/components/form_textarea.html
Normal file
6
template/components/form_textarea.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{{define "form_textarea"}}
|
||||
<div class="input-container">
|
||||
<label for="{{.ID}}" class="form-label">{{.Label}}</label>
|
||||
<textarea class="form-control" id="{{.ID}}" name="{{.ID}}" rows="3"></textarea>
|
||||
</div>
|
||||
{{end}}
|
Loading…
Reference in a new issue