create a cardinality_multiple Entity Autocomplete widget in a custom Drupal 8 form

by MEI   Last Updated January 04, 2018 02:07 AM

in Drupal 8: I am building a custom form to collect values and update 2 different custom entities. One has an entity_autocomplete field which allows multiple values.

How can I build the entity_autocomplete widget that allows multiple entities, ie has the "Add Another Item" functionality?

The following simply puts up one autocomplete widget:

  $form['users']  = array(
    '#type' => 'entity_autocomplete',
    '#title' => t('User(s)'),
    '#target_type' => 'user',
    '#default_value' => '',
    '#weight' => 6,
    '#cardinality_multiple' => true
  );

Many thanks, Mary Edith

Tags : 8 forms entities


Related Questions



Validate File Extension In Drupal 8 Entity Form

Updated March 03, 2016 05:03 AM

Get the Entity form value from radio button

Updated July 31, 2017 21:07 PM