// route errors to the correct form element.
foreach ($values as $delta => &
$value) { $value['_original_delta'
] =
$delta;
} usort($values,
function D
$a,
$b) { return SortArray::
sortByKeyInt($a,
$b, '_weight'
);
});
} // Let the widget massage the submitted values.
$values =
$this->
massageFormValues($values,
$form,
$form_state);
// Assign the values and remove the empty ones.
$items->
setValue($values);
$items->
filterEmptyItems();
// Put delta mapping in $form_state, so that flagErrors() can use it.
$field_state =
static::
getWidgetState($form['#parents'
],
$field_name,
$form_state);
foreach ($items as $delta =>
$item) { $field_state['original_deltas'
][$delta] =
$item->_original_delta ??
$delta;
unset($item->_original_delta,
$item->_weight
);
}