Form and multiple fields on the same line

I am using Form component and FormFieldFactory.
the FormFieldFactory puts all of the fields on their own line.
My question is can I use the Form and FormFieldFactory and put more then one field like State and Zip Code on the same line? Is there an example?
I have posted this question previously and the answer was to create another form for State and Zip when creating fields for the original form.

Does anyone has an example of how to do this, I can not get it work? When I create another form the fields are indented since the new form is inside the main form. So I don’t think I am doing this correctly.

I need:

Zip Code: ________________
City: _____________ St: __

When user enters zip code the program fill populate the City and the State.

Thank You


Hi, Peter!

In this case, perhaps a CustomLayout as the layout in your Form would be the easiest solution? When you set a CustomLayout as the layout of a form, the fields are placed in custom layout locations named after the property id.

    public void addField(Object propertyId, Field field) {
            if (layout instanceof CustomLayout) {
                ((CustomLayout) layout).addComponent(field, propertyId

The book contains
more info on CustomLayouts


Ticket #2205
will probably help you, once it is fixed.

Thanks for your help!

But I guess I will have to use the CustomLayout.

I have tried the new FormWithComplexLayout Layout and it does not solve my problem. The problem with the FormWithComplexLayout is the GridLayout. If field1 is on the first row and it’s very long and you want to put 2 fields on the second row, the second field on the second row is aligned with the end of the first field on the first row.

example of FormWithComplexLayout:


Zip Code: State:

and what I am looking for is:


Zip Code: _________ State:____