diff --git a/content/docs/_index.md b/content/docs/_index.md index 74d7218..4a7b3d7 100644 --- a/content/docs/_index.md +++ b/content/docs/_index.md @@ -12,15 +12,3 @@ Creating and processing HTML forms is hard and repetitive. You need to deal with * Data mounting to populate a form from a struct instance * Data binding to populate a struct instance from a submitted form * Form renderer with customizable themes - - diff --git a/content/docs/fields/_index.md b/content/docs/fields/_index.md index 00af9ea..63fb9be 100644 --- a/content/docs/fields/_index.md +++ b/content/docs/fields/_index.md @@ -12,9 +12,9 @@ A field represents a field in a form. func NewFieldCheckbox(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=checkbox] @@ -24,11 +24,11 @@ Generates an input[type=checkbox] func NewFieldChoice(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates inputs (checkbox or radio) or selects @@ -39,11 +39,11 @@ Generates inputs (checkbox or radio) or selects func NewFieldCsrf(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} ### Date @@ -51,11 +51,11 @@ field := form.NewFieldCsrf("Foo") func NewFieldDate(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=date] with default transformers @@ -65,11 +65,11 @@ Generates an input[type=date] with default transformers func NewFieldDatetime(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=datetime] with default transformers @@ -79,11 +79,11 @@ Generates an input[type=datetime] with default transformers func NewFieldDatetimeLocal(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=datetime-local] with default transformers @@ -93,11 +93,11 @@ Generates an input[type=datetime-local] with default transformers func NewFieldHidden(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=hidden] @@ -107,11 +107,11 @@ Generates an input[type=hidden] func NewFieldMail(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=email] @@ -121,11 +121,11 @@ Generates an input[type=email] func NewFieldNumber(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=number] with default transformers @@ -135,11 +135,11 @@ Generates an input[type=number] with default transformers func NewFieldPassword(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=password] @@ -149,11 +149,11 @@ Generates an input[type=password] func NewFieldRange(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=range] @@ -163,11 +163,11 @@ Generates an input[type=range] func NewFieldSubForm(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Alias: @@ -183,11 +183,11 @@ Generates a sub form func NewFieldText(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=text] @@ -197,11 +197,11 @@ Generates an input[type=text] func NewFieldTextarea(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates a textarea @@ -211,11 +211,11 @@ Generates a textarea func NewFieldTime(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=time] with default transformers @@ -225,11 +225,11 @@ Generates an input[type=time] with default transformers func NewSubmit(name string) *Field ``` -{{% gpfield %}} +{{% goplay-field %}} -{{% /gpfield %}} +{{% /goplay-field %}} Generates an input[type=submit] diff --git a/content/docs/rendering/_index.md b/content/docs/rendering/_index.md index 4651543..34ab249 100644 --- a/content/docs/rendering/_index.md +++ b/content/docs/rendering/_index.md @@ -10,7 +10,8 @@ Here is a simple example that displays a form: ```golang myForm := form.NewForm(...) -render := theme.NewRenderer(theme.Html5) +render := theme.NewRenderer(theme.Bootstrap5) + tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` @@ -22,18 +23,39 @@ tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` `) +b := new(strings.Builder) + tpl.Execute(w, map[string]any{ "Form": myForm, }) -tpl, _ := template.New("example").Funcs(render.FuncMap()).Parse("{{ form_widget .Form }}") - -b := new(strings.Builder) -tpl.Execute(b, map[string]any{"Form": f}) - fmt.Println(b.String()) ``` +{{% goplay-auto-import-main %}} + +{{% /goplay-auto-import-main %}} + Other helper functions are available to render specific parts of the form: - `form_errors`: displays the form's global errors diff --git a/layouts/shortcodes/goplay.html b/layouts/shortcodes/goplay.html deleted file mode 100644 index 3cbe76e..0000000 --- a/layouts/shortcodes/goplay.html +++ /dev/null @@ -1,81 +0,0 @@ -{{ $id := md5 .Inner }} {{ .Inner }} - -
-
- - - -
- - - - diff --git a/layouts/shortcodes/gpfield.html b/layouts/shortcodes/gpfield.html deleted file mode 100644 index 5762a16..0000000 --- a/layouts/shortcodes/gpfield.html +++ /dev/null @@ -1,143 +0,0 @@ -{{ $id := md5 .Inner }} {{ .Inner }} - -
-Test me - -
-
- - - -
-
- - - -