绑定HTML复选框

最后更新于:2022-04-02 07:26:43

[查看详细信息](https://github.com/gin-gonic/gin/issues/129#issuecomment-124260092) main.go ``` ... type myForm struct { Colors []string `form:"colors[]"` } ... func formHandler(c *gin.Context) { var fakeForm myForm c.ShouldBind(&fakeForm) c.JSON(200, gin.H{"color": fakeForm.Colors}) } ... ``` form.html ```

Check some colors

``` result: ``` {"color":["red","green","blue"]} ```
';