protected function formMultipleElements(FieldItemListInterface
$items, array &
$form, FormStateInterface
$form_state) { $field_name =
$this->fieldDefinition->
getName();
$parents =
$form['#parents'
];
// Load the items for form rebuilds from the field state as they might not
// be in $form_state->getValues() because of validation limitations. Also,
// they are only passed in as $items when editing existing entities.
$field_state =
static::
getWidgetState($parents,
$field_name,
$form_state);
if (isset($field_state['items'
])) { $items->
setValue($field_state['items'
]);
} // Determine the number of widgets to display.
$cardinality =
$this->fieldDefinition->
getFieldStorageDefinition()->
getCardinality();
switch ($cardinality) { case FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED:
$max =
count($items);
$is_multiple = TRUE;
break;