I don’t see an addFormItem() method which would allow to add an item completely without the label (since I prefer to simply name the form fields and have the labels above them). So I have to use “” as the label (null doesn’t work as the method becomes ambiguous. The problem with this approach is that the label is still there (in shadow CSS). That creates unnecessary side blank space.
Anyone? I guess this should be possible as it really don’t make sense to use for example labels directly on a TextField (which will then be shown above the field) and to retain blank space on the left where no label was explicitly set (or in this case: it was set but as “”).
Jouni Koivuviita:
At least you should be able to use the low-level Element API to inject content to FormLayout (assuming the question relates to that).
Something like this:
FormLayout form = new FormLayout();
TextField field = new TextField("Label");
form.getElement().appendChild(field.getElement());
I actually tried this one:
TextField myTxtField = new TextField("label");
addFormItem(myTxtField, myTxtField);
As you can see, I pass again the field itself, instead of new Label("label"). And it does the job - no blank space and label in shadow CSS on the left side and the label is shown above the field. However, there is drawback to this approach - now the added full-size class to all the fields has no effect.