How do I get multiple references from the autocomplete? I am using the following form element.

$form['group']['one'] = array(
    '#type' =&gt; 'entity_autocomplete',
    '#title' =&gt; t('Tags'),
    '#target_type' =&gt; 'user',
);


I submit values similar to the following ones.


  user00 (0), user01 (1), user02 (2), user0x (3)


What I receive from the form is the following:


  one = 3


It only picks up the last ID.

How can I get all the references entered in the form element? How does the form element handle the references to not existing entities?
The comma is used to separate multiple references, but looking at the code in Name::valueForm() I would say the form element needs to use a property more.

  $form['value'] = array(
    '#type' =&gt; 'entity_autocomplete',
    '#title' =&gt; $this-&gt;t('Usernames'),
    '#description' =&gt; $this-&gt;t('Enter a comma separated list of user names.'),
    '#target_type' =&gt; 'user',
    '#tags' =&gt; TRUE,
    '#default_value' =&gt; $default_value,
    '#process_default_value' =&gt; $this-&gt;isExposed(),
  );


Settings #tags to TRUE makes the the form element accept multiple values.

The format of the values assigned to the form element is evident in EntityAutocomplete::validateEntityAutocomplete() (its validation handler), which uses this code.

  $input_values = $element['#tags'] ? Tags::explode($element['#value']) : array($element['#value']);

  foreach ($input_values as $input) {
    $match = static::extractEntityIdFromAutocompleteInput($input);
    if ($match === NULL) {
      // Try to get a match from the input string when the user didn't use
      // the autocomplete but filled in a value manually.
      $match = static::matchEntityByTitle($handler, $input, $element, $form_state, !$autocreate);
    }

    if ($match !== NULL) {
      $value[] = array(
        'target_id' =&gt; $match,
      );
    }
    elseif ($autocreate) {
      /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
      // Auto-create item. See an example of how this is handled in
      // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
      $value[] = array(
        'entity' =&gt; $handler-&gt;createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']),
      );
    }


The form element value is an array of item whose target_id key is an object of the requested entity.

(From that code, it is also clear that #tags makes the form element accepts multiple references separated by commas.) 

As for the using reference that aren't found, you can decide what the autocomplete does by setting #validate_reference: If you set it to TRUE, and #autocreate is not set to TRUE, the autocomplete will accept only existing references.