diff --git a/serializer.js b/serializer.js
index f7f44d5..c0b2d8f 100644
--- a/serializer.js
+++ b/serializer.js
@@ -32,7 +32,16 @@ class SerializerField {
*/
serialize() {
if (this.field.tagName == "SELECT" && this.field.multiple) {
- return Array.apply(null, this.field.options).filter(o => o.selected).map(o => o.value)
+ return Array.apply(null, this.field.options).filter(o => o.selected).map(o => {
+ let name = o.getAttribute("name") || false
+ if(!name){
+ return o.value
+ }
+ let v = {}
+ v[name] = o.value
+
+ return v
+ })
}
if (this.type == "number" || this.type == "range") {
diff --git a/tests/main.go b/tests/main.go
index a54198d..e00e959 100644
--- a/tests/main.go
+++ b/tests/main.go
@@ -28,6 +28,11 @@ var testData = []*Person{
Checklist: []string{
"Milk",
},
+ JSON: []JSON{
+ {
+ Value: "value",
+ },
+ },
},
nil,
&Person{
@@ -56,6 +61,11 @@ var testData = []*Person{
Checklist: []string{
"Milk",
},
+ JSON: []JSON{
+ {
+ Value: "value",
+ },
+ },
},
}
@@ -94,6 +104,12 @@ type Person struct {
Languages []Language `json:"languages"`
Checklist []string `json:"checklist"`
Animal string `json:"animal"`
+ JSON []JSON `json:"json"`
+}
+
+// JSON ...
+type JSON struct {
+ Value string `json:"key"`
}
// Language ...
@@ -154,6 +170,9 @@ func isEq(p1, p2 Person) {
for k := range p2.Checklist {
assert(p1.Checklist[k], p2.Checklist[k], "Checklist")
}
+ for k := range p2.JSON {
+ assert(p1.JSON[k], p2.JSON[k], "JSON")
+ }
}
func assert(v, v2 interface{}, ident string) bool {
diff --git a/tests/templates/test.gohtml b/tests/templates/test.gohtml
index de6b175..65740ca 100644
--- a/tests/templates/test.gohtml
+++ b/tests/templates/test.gohtml
@@ -37,6 +37,9 @@
+