go-app
go-app copied to clipboard
Form().EncType() doesn't result in setting enctype in rendered form.
When calling app.Form().EncType("multipart/form-data")
the encoding type isn't set on the form.
Code to reproduce:
package main
import (
"github.com/maxence-charriere/go-app/v6/pkg/app"
)
type order struct {
app.Compo
firstName string
lastName string
}
func (o *order) Render() app.UI {
return app.Div().Body(
app.Main().Body(
app.H1().Body(
app.Text("icanhazprint?"),
),
app.Form().
Method("post").Action("/api/v1/create-order").
EncType("multipart/form-data").
Body(
app.Input().Value(o.firstName).Placeholder("What is your first name?").AutoFocus(true),
app.Input().Value(o.lastName).Placeholder("What is your last name?"),
app.Input().Type("file").Name("image").Placeholder("File"),
app.Input().Type("submit").Value("Submit"),
),
),
)
}
func main() {
app.Route("/", &order{})
app.Run()
}
Expected results:
Chrome Version 83.0.4103.116 (Official Build) (64-bit) (Ubuntu, installed from deb)
form has enctype="multipart/form-data"
attribute.
<form action="/api/v1/create-order" enctype="multipart/form-data" method="post" _lpchecked="1"><input value="" placeholder="What is your first name?" autofocus=""><input value="" placeholder="What is your last name?"><input placeholder="File" type="file"><input type="submit" value="Submit"></form>
Actual Results:
Form is missing enctype="multipart/form-data"
attribute.
<form action="/api/v1/create-order" method="post" _lpchecked="1"><input value="" placeholder="What is your first name?" autofocus=""><input value="" placeholder="What is your last name?"><input placeholder="File" type="file"><input type="submit" value="Submit"></form>
go version go1.14.2 linux/amd64
if that helps.
What's strange is that Method()
works correctly but EncType()
doesn't. I dug around in html.go
and saw that Method()
and EncType()
set attributes the same way.
I also tried app.Input().Type("submit").Value("Submit").FormEncType("multipart/form-data"),
but that didn't work either. Digging around in html.go there doesn't appear to be a Submit
type, just Button
and Input
.