Changing 2 Elements on Ajax Callback I have an element $form['elements']['manufacturer']. On change, I want to change $form['elements']['form_factor'] and $form['elements']['model'].
Currently I have:
$form['elements']['manufacturer']['#ajax'] = [
    'callback' =&gt; 'formChanged',
    'wrapper' =&gt; 'form-factor',
    'event' =&gt; 'change',
];

which works and changes the form-factor. But, I want to change the model as well.
Iniside formChanged return form-factor in the callback function, so I can't return model element.
function formChanged(array &amp;$form, FormStateInterface $formState){
  $form[&quot;elements&quot;][&quot;form_factor&quot;][&quot;#value&quot;] = 0;
  return $form[&quot;elements&quot;][&quot;form_factor&quot;];
}

Reading from past posts, one option was to return the whole form inside formChanged (return $form), but this doesn't seem like a good approach.
I can't do something like, having 2 callbacks:
$form['elements']['manufacturer']['#ajax'] = [
   [
    'callback' =&gt; 'formChanged',
    'wrapper' =&gt; 'form-factor',
    'event' =&gt; 'change',
   ],
   [
    'callback' =&gt; 'anothercallback',
    'wrapper' =&gt; 'another-one',
    'event' =&gt; 'change',
   ]
];
Instead of returning a single render array (of all or part of your form) from your callback, you will need to return an AjaxResponse that contains a  ReplaceCommand for each piece of the form you want to replace:
For example, in your callback:
$response = new AjaxResponse();
$response
  -&gt;addCommand(new ReplaceCommand('#edit-form-factor', $form_factor_element))
  -&gt;addCommand(new ReplaceCommand('#edit-model', $model_element));
return $response;

See the guide:
https://www.drupal.org/docs/drupal-apis/ajax-api/basic-concepts#sub_form
And the Ajax commands reference:
https://www.drupal.org/docs/drupal-apis/ajax-api/core-ajax-callback-commands