From 90564daa5bdc4010c9b95c563cb9d0d8623492e0 Mon Sep 17 00:00:00 2001 From: Zeni Kim Date: Tue, 17 Dec 2024 14:26:57 -0500 Subject: [PATCH] improve GetRequestForm, extend templates --- context.go | 5 +++-- template/components/content_table.go | 2 +- template/components/content_table.html | 4 ++++ template/components/form_checkbox.html | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index ad1321d..fba3e7a 100644 --- a/context.go +++ b/context.go @@ -68,8 +68,9 @@ func (c *Context) RequestParamExists(key string) bool { return c.Request.httpRequest.Form.Has(key) } -func (c *Context) GetRequesForm() interface{} { - return c.Request.httpRequest.Form +func (c *Context) GetRequesForm(key string) interface{} { + c.Request.httpRequest.ParseForm() + return c.Request.httpRequest.Form[key] } func (c *Context) GetRequesBodyMap() map[string]interface{} { diff --git a/template/components/content_table.go b/template/components/content_table.go index 1cb7024..9e77908 100644 --- a/template/components/content_table.go +++ b/template/components/content_table.go @@ -10,7 +10,7 @@ type ContentTable struct { type ContentTableTH struct { ID string - ValueType string // -> default string, href, badge + ValueType string // -> default string, href, badge, list, checkbox Value string } diff --git a/template/components/content_table.html b/template/components/content_table.html index 2bf559d..e5aaf50 100644 --- a/template/components/content_table.html +++ b/template/components/content_table.html @@ -13,6 +13,10 @@ {{template "content_href" $item.Value}} {{ else if eq $x.ValueType "badge"}} {{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 }} {{ $item.Value }} {{end}} diff --git a/template/components/form_checkbox.html b/template/components/form_checkbox.html index 9a8d845..992cff0 100644 --- a/template/components/form_checkbox.html +++ b/template/components/form_checkbox.html @@ -1,6 +1,6 @@ {{define "form_checkbox"}}
- + {{ if .Label }}{{end}} {{range $options := .AllCheckbox}}