[WIP] feat: add collection widget

This commit is contained in:
Simon Vieille 2025-09-24 09:03:50 +02:00
commit a06afe583d
Signed by: deblan
GPG key ID: 579388D585F70417
8 changed files with 367 additions and 30 deletions

View file

@ -36,12 +36,18 @@ type ExampleDates struct {
}
type ExampleData struct {
Bytes []byte
Text string
Checkbox bool
Dates ExampleDates
Choices ExampleChoices
Inputs ExampleOtherInputs
Collection []CollectionItem
Bytes []byte
Text string
Checkbox bool
Dates ExampleDates
Choices ExampleChoices
Inputs ExampleOtherInputs
}
type CollectionItem struct {
ValueA string
ValueB string
}
func CreateDataForm() *form.Form {
@ -60,6 +66,19 @@ func CreateDataForm() *form.Form {
})
return form.NewForm(
form.NewFieldCollection("Collection").
WithOptions(
form.NewOption("label", "Collection"),
form.NewOption("form", form.NewForm(
form.NewFieldText("ValueA").
WithOptions(form.NewOption("label", "Value A")).
WithConstraints(
validation.NewNotBlank(),
),
form.NewFieldText("ValueB").
WithOptions(form.NewOption("label", "Value B")),
)),
),
form.NewFieldText("Bytes").
WithOptions(
form.NewOption("label", "Bytes"),