Not quite sure what you meant, but if you want all fields to be horizontal, then you can call form.setLayout(new HorizontalLayout());. If you want to place some of the fields horizontally and others vertically, then you’ll probably need to use another layout such as GridLayout and use the advanced form features for setting the components to their correct positions. To see an example of how to do this, click on the “view source” in the link you provided.
For point 3 and the Vaadin example, If field label and input box need to be displayed in the same line (no change for the form layout), what should the style be?
I am wondering whether the attached screenshot could be implemented by setting form/layout styles only.
Field label and input box are in the same line by default (see http://demo.vaadin.com/sampler#FormBasic ). If the form wrapped with advanced layout (GridLayout) workes in the same way, I am afraid it should be implemented with coding.
Something related to the approach 2) is discussed
in this thread .
Use a CustomLayout (defined as HTML)
Use CssLayout and some CSS to tell what goes where etc.
(Yes, there should and will be better ways to do this.)
I would probably go with option 1 (with some helper class based on FieldWrapper, containing a lightweight layout such as CssLayout or WeeLayout from the directory) or 2 (with a Form subclass that handles this automatically in attachField).
Each approach has advantages and disadvantages; for instance, the placement and presence of the “required” and “error” indicators depends on the approach taken, and some are more complicated in your code or complicate the DOM structure more than others (potentially slowing down layouting on the browser a little).
}
[/code]It’s crazy people have to ask such things that are so simple in classic web pages.
I also find this in the documentation (note the newsletter field)
https://demo.vaadin.com/valo-theme/#!forms