Add checkbox test

This commit is contained in:
Crow Crowcrow 2017-08-27 14:21:06 +02:00
parent c672ec1666
commit 6531a2f107
3 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,8 @@ class SerializerField {
return Number(this.field.value);
} else if(type == "date" || type == "datetime-local" || type == "month" || type == "week") {
return new Date(this.field.value);
} else if(type == "checkbox") {
return this.field.checked;
} else {
return this.field.value;
}

View File

@ -36,14 +36,17 @@ var testData = []*Person{
Language{
Language: "Dutch",
SkillLevel: 9.99,
Native: true,
},
Language{
Language: "English",
SkillLevel: 8.4,
Native: false,
},
Language{
Language: "Marokaans",
Language: "Japanese",
SkillLevel: -9000.9,
Native: false,
},
},
},
@ -86,6 +89,7 @@ type Person struct {
type Language struct {
Language string `json:"language"`
SkillLevel float64 `json:"skill_level"`
Native bool `json:"native"`
}
func getTest(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@ -120,6 +124,7 @@ func isEq(p1, p2 Person) {
for k := range p1.Languages {
assert(p1.Languages[k].Language, p2.Languages[k].Language, "Languages.Language")
assert(p1.Languages[k].SkillLevel, p2.Languages[k].SkillLevel, "Languages.SkillLevel")
assert(p1.Languages[k].Native, p2.Languages[k].Native, "Languages.Native")
}
}

View File

@ -26,6 +26,7 @@
{{ range $p.Languages }}
<group name="[]languages">
<input name="language" type="text" value="{{ .Language }}">
<input name="native" type="checkbox" {{ if .Native }} checked {{ end }}>
<input name="skill_level" type="number" value="{{ .SkillLevel }}">
</group>
{{ end }}