Forms and Input handling

Forms and Input Handling

Creating forms is straightforward with gofh:

gofh.Form(
    gofh.Input("text", "username").Placeholder("Username"),
    gofh.Input("password", "password").Placeholder("Password"),
    gofh.Button("Submit").Type("submit"),
).HxPost("/login").HxSwap("outerHTML")

Handling form submissions:

app.Post("/login").Handle(func(c *gofh.Context) gofh.Element {
    username := c.GetFormValue("username")
    password := c.GetFormValue("password")
    // Process login...
    return gofh.P("Login successful!")
})

Last updated