2 Answers
2

You use entity_autocomplete as #type for the form field. CommentForm::form() contains such a form field, for the administrator users to be able to change the author of a comment. This is the code it uses.

+1 on documenting your way of finding this but you might to include a code sample too from the last link otherwise someone will comment that you should do so. Which I just did ;)
– BerdirNov 5 '15 at 23:05