+
+
diff --git a/404.html b/404.html new file mode 100644 index 0000000..5e6a065 --- /dev/null +++ b/404.html @@ -0,0 +1,39 @@ + + + +
+Creating and processing HTML forms is hard and repetitive. You need to deal with rendering HTML form fields, validating submitted data, mapping the form data into objects and a lot more. go-form includes a powerful form feature that provides all these features.
+go-form is heavily influenced by Symfony Form. It includes:
+fmt.Sprintf("foo")| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
| ok | +
import (
+ "net/http"
+
+ "gitnet.fr/deblan/go-form/form"
+)
+
+type Person struct {
+ Name string
+ Age int
+}
+
+func createForm() *form.Form {
+ f := form.NewForm()
+
+ // do stuff
+
+ return f
+}
+
+http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ alice := Person{
+ Name: "Alice",
+ Age: 42,
+ }
+
+ myForm := createForm()
+
+ if r.Method == myForm.Method {
+ myForm.HandleRequest(r)
+
+ if myForm.IsSubmitted() && myForm.IsValid() {
+ myForm.Bind(&data)
+ }
+ }
+})A form is a struct containing:
+import (
+ "net/http"
+
+ "gitnet.fr/deblan/go-form/form"
+)// Let's create a new form
+// You can pass *form.Field as arguments
+myForm := form.NewForm(field1, field2, ...)
+
+// Add somes fields
+myForm.Add(field3, field4, ...)
+
+// Set the method
+// <form method="POST" ...>
+myForm.WithMethod(http.MethodPost)
+
+// Define the action
+// <form action="/" ...>
+myForm.WithAction("/")
+
+// Set a name
+myForm.WithName("myForm")
+
+// Add options
+myForm.WithOptions(option1, option2, ...)
+
+// When all fields are added, call End()
+myForm.End()Some options are natively supported in go-form themes.
+myForm.WithOptions(
+ form.NewOption("help", "A help for the form"),
+ // <form data-foo="bar" data-bar="bar" ...
+ form.NewOption("attr", map[string]string{
+ "data-foo": "foo",
+ "data-bar": "bar",
+ }),
+)type Person struct {
+ Name string
+ Age int
+}
+
+alice := Person{
+ Name: "Alice",
+ Age: 42,
+}
+
+// Assuming 2 fields named "Name" and "Age" exist
+myForm.Mount(alice)Creating and processing HTML forms is hard and repetitive. You need to deal with rendering HTML form fields, validating submitted data, mapping the form data into objects and a lot more. go-form includes a powerful form feature that provides all these features.
+go-form is heavily influenced by Symfony Form. It includes:
+fmt.Sprintf("foo")Creating and processing HTML forms is hard and repetitive. You need to deal with rendering HTML form fields, validating submitted data, mapping the form data into objects and a lot more. go-form includes a powerful form feature that provides all these features.
+go-form is heavily influenced by Symfony Form. It includes:
+fmt.Sprintf("foo")