Frontend: Forms

Creating and processing forms using HB in Dracory.

Working with Forms

Forms are an essential part of web applications. Dracory makes it easy to create and process forms using the HB package.

func createForm() hb.TagInterface {
    return hb.Form().
        Method("POST").
        Action("/submit").
        Child(hb.Div().
            Class("form-group").
            Child(hb.Label().For("name").Text("Name")).
            Child(hb.Input().
                Type("text").
                ID("name").
                Name("name").
                Class("form-control").
                Placeholder("Enter your name"))).
        Child(hb.Div().
            Class("form-group").
            Child(hb.Label().For("email").Text("Email")).
            Child(hb.Input().
                Type("email").
                ID("email").
                Name("email").
                Class("form-control").
                Placeholder("Enter your email"))).
        Child(hb.Button().
            Type("submit").
            Class("btn btn-primary").
            Text("Submit"))
}
Menu