Remove an item from $form_state in an ajax callback
$form_state->setValues(['names_fieldset'], array_values($values));


setValues(array $values) only has 1 parameter

For 2 params, you need to use setValue($key, $value) without the "s"

$form_state-&gt;setValue('name', array_values($values));  




Alternatively, you could do

$values = $form_state-&gt;getValues();
$values['name'] = array_values($values);
$form_state-&gt;setValues($values);