Get an Un-submitted/Active Form Field Value in $form_state?
MYMODULE/src/Form.php:

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {

  // get form config.
  $config = $this-&gt;config('MYMODULE.settings');

  // Set our count. Used in for loop below.
  if (!empty($form_state-&gt;getValue(['fieldset', 'field_count']))) {
    // get $form_state count value.
    $defaultCount = $form_state-&gt;getValue(['fieldset', 'field_count']);
  }
  else {
    // Get config count value.
    $defaultCount = $config-&gt;get('field_count');
  }

  $form['#tree'] = TRUE;

  // Fieldset item.
  $form['fieldset'] = [
    '#type' =&gt; 'fieldset',
    '#prefix' =&gt; '&lt;div id="fieldset-wrapper"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  ];

  // Field count item.
  $form['fieldset']['field_count'] = [
    '#type' =&gt; 'number',
    '#title' =&gt; 'Number',
    '#required' =&gt; TRUE,
    '#default_value' =&gt; $config-&gt;get('field_count') ?: 1,
  ];

  // Rebuild submit item.
  $form['fieldset']['rebuild'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Apply number',
    '#submit' =&gt; ['::rebuildFormSubmit'],
    '#ajax' =&gt; [
      'callback' =&gt; '::fieldCallback',
      'wrapper' =&gt; 'fieldset-wrapper',
    ],
  ];

  // Loop through our count and create form items.
  for ($i = 0; $i &lt; $defaultCount; $i++) {

    $form['fieldset']['field'][$i] = [
      '#type' =&gt; 'textfield',
      '#default_value' =&gt; isset($config-&gt;get('script')[$i]) ? $config-&gt;get('script')[$i] : '',
    ];

  }

  return parent::buildForm($form, $form_state);

}

/**
 * {@inheritdoc}
 */
public function fieldCallback(array &amp;$form, FormStateInterface $form_state) {
  return $form['fieldset'];
}

/**
 * {@inheritdoc}
 */
public function rebuildFormSubmit(array &amp;$form, FormStateInterface $form_state) {
  $form_state-&gt;setRebuild(TRUE);
}


This part in the $form['fieldset']['rebuild']:

'#ajax' =&gt; [
  'callback' =&gt; '::fieldCallback',
  'wrapper' =&gt; 'fieldset-wrapper',
],


along with:

/**
 * {@inheritdoc}
 */
public function fieldCallback(array &amp;$form, FormStateInterface $form_state) {
  return $form['fieldset'];
}


Are the ajax options.