Hello, can we use *Panel (SplitPanel, HPanel....) ...
# kvision
j
Hello, can we use *Panel (SplitPanel, HPanel....) in a FormPanel without loose databiding ? How can I manage my form layout ?
r
FormPanel
was designed to be an example implementation of visual form component. The form logic is extracted to the
From
class, so
FormPanel
is just taking care of visualization. I've assumed users can just implement their own FormPanels.
So at the moment if you want customize your form layout, you need to create your own class similar to
FormPanel
.
But as
FormPanel
become quite complex, I'll take a look if something can be improved to make it more reusable.
I've added additional
customContainer
parameter for the
FormPanel
class. It will be available in 4.1.0 (I plan the release for this weekend). It will work like this:
Copy code
formPanel<Form>(customContainer = HPanel(spacing = 20)) {
                add(Form::text, Text(label = "Text 1"))
                add(Form::text2, TextArea(label = "Text 2"))
            }
Please let me know it this change meets your needs.
j
Sorry for not answering over the weekend. If I understand correctly "customContainer" allows to change the "root" container of the form ? But it doesn't allow me to manage the whole layout ? Like a DSL build ?
r
So a different approach. No need to define any custom container. Use any layout you like, just bind the controls to the form with an extension function
bind
. Like this:
Copy code
formPanel<Form> {
	hPanel(spacing = 5) {
		text(label = "text 1").bind(Form::text, required = true)
		vPanel(spacing = 5) {
			textArea(label = "text 2").bind(Form::text2)
			textArea(label = "text 3").bind(Form::text3)
		}
	}
}
What do you think? I personally really like this idea.
j
Yes I like it ! Thank you for considering my request !