How to align accordion in form. #4055
-
How to left align the accordion to the form so that the detail items are listed. Right now, it's off to the 2nd column. Please let me know if there is a better way to include the accordion in the form and properly aligned. package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Accordion - with form")
w.Resize(fyne.NewSize(500, 500))
entry := widget.NewEntry()
textArea := widget.NewMultiLineEntry()
form := &widget.Form{
Items: []*widget.FormItem{
{Text: "Name", Widget: entry}, {Text: "Description", Widget: textArea}},
OnSubmit: func() {
w.Close()
},
}
label1 := widget.NewLabel("City")
value1 := widget.NewEntry()
label2 := widget.NewLabel("State")
value2 := widget.NewEntry()
grid := container.New(layout.NewFormLayout(), label1, value1, label2, value2)
item1 := widget.NewAccordionItem("Address",
grid)
ac := widget.NewAccordion(item1)
form.Append("", ac)
w.SetContent(form)
w.ShowAndRun()
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Did you try to add the accordion when building the form widget ?
Another solution is to not use form widget, and build your own form logic with FormLayout |
Beta Was this translation helpful? Give feedback.
-
The content of a form uses the pattern label (left) and content (fill right) - this is it's entire design. |
Beta Was this translation helpful? Give feedback.
The content of a form uses the pattern label (left) and content (fill right) - this is it's entire design.
If you want to put multiple parts of a form in elements of an accordion then you would need to split the form content into multiple Form widgets inserted into, or around, the accordion.