Merge pull request 'improve GetRequestForm, extend templates' (#17) from develop into main

Reviewed-on: #17
This commit is contained in:
Zeni Kim 2024-12-18 08:19:48 -05:00
commit 0afafd8c41
4 changed files with 9 additions and 4 deletions

View file

@ -68,8 +68,9 @@ func (c *Context) RequestParamExists(key string) bool {
return c.Request.httpRequest.Form.Has(key) return c.Request.httpRequest.Form.Has(key)
} }
func (c *Context) GetRequesForm() interface{} { func (c *Context) GetRequesForm(key string) interface{} {
return c.Request.httpRequest.Form c.Request.httpRequest.ParseForm()
return c.Request.httpRequest.Form[key]
} }
func (c *Context) GetRequesBodyMap() map[string]interface{} { func (c *Context) GetRequesBodyMap() map[string]interface{} {

View file

@ -10,7 +10,7 @@ type ContentTable struct {
type ContentTableTH struct { type ContentTableTH struct {
ID string ID string
ValueType string // -> default string, href, badge ValueType string // -> default string, href, badge, list, checkbox
Value string Value string
} }

View file

@ -13,6 +13,10 @@
{{template "content_href" $item.Value}} {{template "content_href" $item.Value}}
{{ else if eq $x.ValueType "badge"}} {{ else if eq $x.ValueType "badge"}}
{{template "content_badge" $item.Value}} {{template "content_badge" $item.Value}}
{{ else if eq $x.ValueType "list"}}
{{template "content_list" $item.Value}}
{{ else if eq $x.ValueType "checkbox"}}
{{template "form_checkbox" $item.Value}}
{{ else }} {{ else }}
{{ $item.Value }} {{ $item.Value }}
{{end}} {{end}}

View file

@ -1,6 +1,6 @@
{{define "form_checkbox"}} {{define "form_checkbox"}}
<div class="input-container"> <div class="input-container">
<label class="form-label">{{.Label}}</label> {{ if .Label }}<label class="form-label">{{.Label}}</label>{{end}}
{{range $options := .AllCheckbox}} {{range $options := .AllCheckbox}}
<div class="form-check"> <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}}> <input class="form-check-input" type="checkbox" name="{{$options.Name}}" id="{{$options.ID}}" value="{{$options.Value}}"{{if eq $options.IsChecked true}} checked{{end}}>