$description =
$this->
getFilteredDescription();
$elements =
[];
$delta = 0;
// Add an element for every existing item.
foreach ($items as $item) { $element =
[ '#title' =>
$title,
'#description' =>
$description,
];
$element =
$this->
formSingleElement($items,
$delta,
$element,
$form,
$form_state);
if ($element) { // Input field for the delta (drag-n-drop reordering).
if ($is_multiple) { // We name the element '_weight' to avoid clashing with elements
// defined by widget.
$element['_weight'
] =
[ '#type' => 'weight',
'#title' =>
$this->
t('Weight for row @number',
['@number' =>
$delta + 1
]),
'#title_display' => 'invisible',
// Note: this 'delta' is the FAPI #type 'weight' element's property.