Are you trying to do this with ACF fields? Those do not look like ACF field groups to me, although they very well could be. If they are then I would look at the code that is used here to figure out how it’s done.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users