custom form

Create a custom form field for entity reference with auto complete in Drupal 8.

The Entity reference module provides a auto complete field widget and this has been changed to a Form API element as 'entity_autocomplete'. This can be used in normal custom forms. Form element type can be used as 'entity_autocomplete' for entity reference fields. Following is a sample code structure to create a entity reference fields with in custom form.