2017-08-26 23:44:47 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>test</title>
|
|
|
|
<style>
|
|
|
|
form > group{
|
|
|
|
margin: 10px 0;
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
group * {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script src="/static/serializer.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<form id="testform">
|
|
|
|
{{ range $k, $p := . }}
|
|
|
|
{{ if $p }}
|
|
|
|
<group name="[{{ $k }}]">
|
|
|
|
<input name="name" type="text" value="{{ $p.Name }}">
|
|
|
|
<input name="surname" type="text" value="{{ $p.Surname }}">
|
|
|
|
<input name="age" type="number" value="{{ $p.Age }}">
|
|
|
|
<input name="birth_date" type="date" value="{{ $p.BirthDate.Format "2006-01-02" }}">
|
|
|
|
{{ range $p.Languages }}
|
|
|
|
<group name="[]languages">
|
2017-08-29 12:58:02 +02:00
|
|
|
<label>
|
|
|
|
<input name="language" type="text" value="{{ .Language }}">
|
|
|
|
</label>
|
2017-08-27 14:21:06 +02:00
|
|
|
<input name="native" type="checkbox" {{ if .Native }} checked {{ end }}>
|
2017-08-26 23:44:47 +02:00
|
|
|
<input name="skill_level" type="number" value="{{ .SkillLevel }}">
|
|
|
|
</group>
|
|
|
|
{{ end }}
|
2018-05-02 18:04:48 +02:00
|
|
|
<select multiple name="checklist">
|
|
|
|
<option selected value="Milk">Milk</option>
|
|
|
|
<option value="Eggs">Eggs</option>
|
|
|
|
</select>
|
|
|
|
<select name="animal">
|
|
|
|
<option value="Dog" selected>Dog</option>
|
|
|
|
<option value="Cat">Cat</option>
|
|
|
|
</select>
|
2017-08-26 23:44:47 +02:00
|
|
|
</group>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</form>
|
|
|
|
<script>
|
|
|
|
let f = document.getElementById("testform"),
|
|
|
|
s = new Serializer(f);
|
|
|
|
|
|
|
|
fetch("/", {
|
|
|
|
method: 'post',
|
|
|
|
headers: {
|
|
|
|
'Accept': 'application/json',
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(s.serialize())
|
|
|
|
}).then(() => {
|
|
|
|
window.close()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|