Problem/Motivation

There lots of issues where we are applying widgets to entity base fields and lots of them have 'author' field. Comments also have own authors.
And everywhere we manually set Anonymous user to the author value if other value is not available, or not valid, or we fetch default value.

Proposed resolution

Lets create separate Selection handler for entity_reference field that will return anonymous user as fallback. Or it can be done as separate AuthorWidget.

Remaining tasks

User interface changes

No UI changes.

API changes

No API changes.

Comments

andypost’s picture

\Drupal\user\Plugin\entity_reference\selection\UserSelection is there
Probably AuthorWidget is a proper solution here

primsi’s picture

A small note: currently NodeForm->buildEntity looks for a value in the uid field and if there is none it sets the authorship to Anonymous. That doesn't work well with node form display modes that don't have the "Authored by" field and resulting in the base field value being set to uid 0.

amateescu’s picture