Dynamically generated radio buttons share name foreach ($questions as $question_index =&gt; $question) {

      $form['questions'][$question_index]['answer'] = [
        '#type' =&gt; 'radios',
        '#title' =&gt; '',
        '#default_value' =&gt; 1,
        '#options' =&gt; $options,
      ];

    }


I am generating a form like this, but the radio buttons share the same name. I find that weird since I am wrapping it in a dynamic wrapper.

I know that I could add something along: [$question_index]['answer_' . $question_index]

But, is it possible to make it rely on the grouping/container instead?
You can try using #tree:

$form['#tree'] = TRUE;


Or you can add it to only your questions element:

$form['questions']['#tree'] = TRUE;