summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--management/editor/elements.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/management/editor/elements.go b/management/editor/elements.go
index c1c418b..4ea0be0 100644
--- a/management/editor/elements.go
+++ b/management/editor/elements.go
@@ -117,11 +117,15 @@ func Checkbox(fieldName string, p interface{}, attrs, options map[string]string)
i := 0
for k, v := range options {
+ inputAttrs := map[string]string{
+ "type": "checkbox",
+ "value": k,
+ }
+
// check if k is in the pre-checked values and set to checked
- var val string
for _, x := range checked {
if k == x {
- val = "true"
+ inputAttrs["checked"] = "true"
}
}
@@ -129,22 +133,13 @@ func Checkbox(fieldName string, p interface{}, attrs, options map[string]string)
// func since this is for a multi-value name
input := &element{
TagName: "input",
- Attrs: map[string]string{
- "type": "checkbox",
- "checked": val,
- "value": k,
- },
+ Attrs: inputAttrs,
Name: tagNameFromStructFieldMulti(fieldName, i, p),
label: v,
data: "",
viewBuf: &bytes.Buffer{},
}
- // if checked == false, delete it from input.Attrs for clarity
- if input.Attrs["checked"] == "" {
- delete(input.Attrs, "checked")
- }
-
opts = append(opts, input)
i++
}