feat: set lowerCamel strategy

This commit is contained in:
Simon Vieille 2025-08-02 15:01:43 +02:00
commit de71141306
Signed by: deblan
GPG key ID: 579388D585F70417
4 changed files with 16 additions and 11 deletions

View file

@ -8,10 +8,10 @@ import (
)
type Contact struct {
Name string
Email string
Topic string
Message string
Name string `field:"lowerCamel"`
Email string `field:"lowerCamel"`
Topic string `field:"lowerCamel"`
Message string `field:"lowerCamel"`
}
func CreateContactForm(isBoostrap bool) *form.Form {
@ -32,7 +32,7 @@ func CreateContactForm(isBoostrap bool) *form.Form {
})
return form.NewForm(
form.NewFieldText("Name").
form.NewFieldText("name").
WithOptions(
form.NewOption("label", "Your name"),
form.NewOption("required", true),
@ -40,7 +40,7 @@ func CreateContactForm(isBoostrap bool) *form.Form {
form.NewOption("label_attr", form.Attrs{"class": "required"}),
).
WithConstraints(validation.NewNotBlank()),
form.NewFieldMail("Email").
form.NewFieldMail("email").
WithOptions(
form.NewOption("label", "Your e-mail"),
form.NewOption("required", true),
@ -51,13 +51,13 @@ func CreateContactForm(isBoostrap bool) *form.Form {
validation.NewNotBlank(),
validation.NewMail(),
),
form.NewFieldChoice("Topic").
form.NewFieldChoice("topic").
WithOptions(
form.NewOption("label", "Topic"),
form.NewOption("empty_choice_label", ""),
form.NewOption("choices", topics),
),
form.NewFieldTextarea("Message").
form.NewFieldTextarea("message").
WithOptions(
form.NewOption("label", "Message"),
form.NewOption("required", true),

View file

@ -8,7 +8,7 @@ import (
)
type Theme struct {
Value string
Value string `field:"lowerCamel"`
}
func NewTheme() *Theme {
@ -21,7 +21,7 @@ func CreateThemeSelectorForm() *form.Form {
choices.ValueBuilder = func(key int, item any) string { return item.(string) }
return form.NewForm(
form.NewFieldChoice("Value").
form.NewFieldChoice("value").
WithOptions(
form.NewOption("choices", choices),
form.NewOption("label", "Select a theme"),

3
go.mod
View file

@ -3,9 +3,10 @@ module gitnet.fr/deblan/go-form-demo
go 1.23.0
require (
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/spf13/cast v1.9.2 // indirect
github.com/yassinebenaid/godump v0.11.1 // indirect
gitnet.fr/deblan/go-form v1.1.6 // indirect
gitnet.fr/deblan/go-form v1.2.0 // indirect
maragu.dev/gomponents v1.1.0 // indirect
)

4
go.sum
View file

@ -1,3 +1,5 @@
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
@ -14,5 +16,7 @@ gitnet.fr/deblan/go-form v1.1.5 h1:ad4StmMErs5Qrt8pzHOCLcaZyXjTupQtjZ9zsNH/qLQ=
gitnet.fr/deblan/go-form v1.1.5/go.mod h1:b+mDJlGUnFKnym06Mys5uHUskgo6uSlr1NMaQPwmJKY=
gitnet.fr/deblan/go-form v1.1.6 h1:ckT3jktWLnododHhiq0/rRLQQ66ccH+vofGfiCVslW8=
gitnet.fr/deblan/go-form v1.1.6/go.mod h1:b+mDJlGUnFKnym06Mys5uHUskgo6uSlr1NMaQPwmJKY=
gitnet.fr/deblan/go-form v1.2.0 h1:l+M5ZfOqfzL2DRFL0+mOxlGT8cGxN6gyL4eQcoHHeTY=
gitnet.fr/deblan/go-form v1.2.0/go.mod h1:GXN9wJKJZyAfhB23VcYf1l3S0h4nTaDg9mCaAu6pwTw=
maragu.dev/gomponents v1.1.0 h1:iCybZZChHr1eSlvkWp/JP3CrZGzctLudQ/JI3sBcO4U=
maragu.dev/gomponents v1.1.0/go.mod h1:oEDahza2gZoXDoDHhw8jBNgH+3UR5ni7Ur648HORydM=