How to fill select options based on previous select?
I've figured it out on how to do this...

I fill out the #options for the second &lt;select&gt; when I build the form.
I hide it with a #states.

When the user then selects something in the first &lt;select&gt; I use the populateDurationYears method to remove invalid options like this:

$options = [];
if($maxDurationYears != 0) {
  for($i = $minLoanDurationYears-1; $i &lt; $maxDurationYears; $i++) {
    $options[] = ($i+1) . " years";
  }
  $form['loanDurationYears']['#options'] = $options;
}
return $form['loanDurationYears'];


This does the trick :-) No need for AjaxResponse or anything like the ReplaceCommand etc... Keep it simpel Stupid! ;-)