This module provides a way to add multiple entity references in custom forms, similar to the entity reference autocomplete widget but without requiring field storage. It allows developers to create an autocomplete input field with buttons to add and remove individual entity references.
If non-entity custom form require a form element that allows adding entity reference and individual entity need to be added using it's own input field same as "entity_reference_autocomplete" widget with tags=false, this module provides that ability. As "entity_reference_autocomplete" require field storage attached to it, it only works with entity forms. This module is a light weight alternative that can be used for any custom forms. This module is only for developer use.
Features
Allows referencing other entities in a custom form. It provides an entity autocomplete input box and "add more item", "remove" buttons to add multiple reference entities using individual inputs.
Post-Installation
This is for dev use only, after installation this module enables a new FormElement type called "entity_reference_autocomplete_add_more".
Example code:
<?php
$form['field_name'] = [
'#type' => 'entity_reference_autocomplete_add_more',
'#target_type' => 'entity_type',
'#title' => $this->t('Field label'),
'#selection_settings' => ['target_bundles' => ['bundle_name'], 'match_limit' => 15],
'#default_value' => [0=>['target_id' => 123],1=>['target_id' => 234]],
];
?>