Making fields in a FieldGroup "Gone" rather than invisble

Hi,

I have a FieldGroup containing fields for an Entity.

I want to show and hide fields depending on a dropdown, which is fine using setVisible() on the component. However when invisible, the fields still take up the space in the layout, I want a way of rearranging the fields so that ones lower in the page move up the page rather than an ugly gap between fields. Similar to the Android mechanism of “Gone” versus “Visible” where gone means that the field is no longer used in the layout setup.

Is there a way of doing this?

i need the same functionallity in one of my projects. i split one field of my e.g. four fields, contained in one field group, into a seperate field group, so i now have two field group items with either three and one field.
now i went ahead an hid the field in the seperate field group.

Daniel

Hi Danny,

Does that achieve the result? Could you attach a couple of screenshots so I understand your layout? That could also work for me I think

Thats how it looks with all fields visible:
grafik

and changing an option in my application, the two upper checkboxes and the textbox gets hidden:

grafik

the field group beneath them moves to the free area i think thats what you need? it’s really basically only two field group items and i hide the above one.

Daniel

Hi Daniel,

I’m working on a project and want to do the same. Can you please help me with setting up the code?

Regards,

LS.

Hi @LloydS, @dannywall55s, @mark.butler
You can simply remove the field from the FieldGroup using removeField("field_id") method.
For example, let’s assume that you want to delete the email field from the User editor screen. The following code will help you to do so

@Override
public void postInit() {
    fieldGroupLeft.removeField("email");
}

Regards,
Natalia

How can this be done in latest version 7.2 ? Seeing that fieldGroup is no longer used ?

Hi.

FieldGroup works only in screens based on legacy API. The similar functionality for the current API is provided by the Form component.

If you use setVisible(false) on the component it takes no space in the form and other fields are automatically rearranged.

Regards,
Nadezhda.