feat: add data binding
feat: add help
This commit is contained in:
parent
3894fb31e9
commit
cef8567ad3
10 changed files with 140 additions and 44 deletions
|
|
@ -9,27 +9,31 @@ func CreateAddressForm() *form.Form {
|
|||
return form.NewForm(
|
||||
form.NewFieldText("Name").
|
||||
WithOptions(
|
||||
form.Option{Name: "label", Value: "Name"},
|
||||
form.Option{Name: "required", Value: true},
|
||||
form.NewOption("label", "Name"),
|
||||
form.NewOption("required", true),
|
||||
form.NewOption("help", "A help!"),
|
||||
).
|
||||
WithConstraints(
|
||||
validation.NotBlank{},
|
||||
),
|
||||
form.NewSubForm("Address").
|
||||
WithOptions(form.Option{Name: "label", Value: "Address"}).
|
||||
WithOptions(form.NewOption("label", "Address")).
|
||||
Add(
|
||||
form.NewFieldTextarea("Street").
|
||||
WithOptions(form.Option{Name: "label", Value: "Street"}).
|
||||
WithOptions(form.NewOption("label", "Street")).
|
||||
WithConstraints(
|
||||
validation.NotBlank{},
|
||||
),
|
||||
form.NewFieldText("City").
|
||||
WithOptions(form.Option{Name: "label", Value: "City"}).
|
||||
WithOptions(form.NewOption("label", "City")).
|
||||
WithConstraints(
|
||||
validation.NotBlank{},
|
||||
),
|
||||
form.NewFieldNumber("ZipCode").
|
||||
WithOptions(form.Option{Name: "label", Value: "Zip code"}).
|
||||
WithOptions(
|
||||
form.NewOption("label", "Zip code"),
|
||||
form.NewOption("help", "A field help"),
|
||||
).
|
||||
WithConstraints(
|
||||
validation.NotBlank{},
|
||||
),
|
||||
|
|
@ -41,8 +45,9 @@ func CreateAddressForm() *form.Form {
|
|||
// WithMethod("GET").
|
||||
WithAction("/").
|
||||
WithOptions(
|
||||
form.Option{Name: "attr", Value: map[string]string{
|
||||
form.NewOption("attr", map[string]string{
|
||||
"id": "my-form",
|
||||
}},
|
||||
}),
|
||||
form.NewOption("help", "A form help!"),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue