html - How to parse form array in golang Beego -
how parse html form array beego.
<input name="names[]" type="text" /> <input name="names[]" type="text" /> <input name="names[]" type="text" />
go beego
type rsvp struct { id int `form:"-"` names []string `form:"names[]"` } rsvp := rsvp{} if err := this.parseform(&rsvp); err != nil { //handle error } input := this.input() fmt.printf("%+v\n", input) // map[names[]:[name1 name2 name3]] fmt.printf("%+v\n", rsvp) // {names:[]}
why beego parseform method return empty names?
how values rsvp.names?
as can see implementation of formvalue method of request, returns first value in case of multiple ones: http://golang.org/src/pkg/net/http/request.go?s=23078:23124#l795 better attribute r.form[key] , iterate on results manually. not sure how beego works, using raw request.parseform , request.form or request.postform maps should job. http://golang.org/src/pkg/net/http/request.go?s=1939:6442#l61
Comments
Post a Comment