Replace #groups with #fieldgroups to avoid clashes. Set the entity type on element, so we can use it