1.6 KiB
1.6 KiB
| linkTitle | title | weight |
|---|---|---|
| Fields | Fields | 3 |
The documentation of field is realised with this program.
import (
"bytes"
"fmt"
"html/template"
"gitnet.fr/deblan/go-form/form"
"gitnet.fr/deblan/go-form/theme"
)
func main() {
myForm := form.NewForm(
// the documented field here
// form.NewField...
).
WithName("form").
End()
render := theme.NewRenderer(theme.Html5)
tpl, _ := template.New("example").Funcs(render.FuncMap()).Parse(`{{- form .Form -}}`)
var buffer bytes.Buffer
tpl.Execute(&buffer, map[string]any{
"Form": myForm,
})
fmt.Print(buffer.String())
}
Common options
| Name | type | description | Info |
|---|---|---|---|
required |
bool |
Add required="true" |
Does not apply a constraint |
attr |
map[string]string |
List of extra attributes of the field | |
row_attr |
map[string]string |
List of extra attributes of the field's top container | |
label |
string |
The label of the field | Usually show before the field |
label_attr |
map[string]string |
List of extra attributes of the label | |
help |
string |
Helper of the field |