feat: #3610995 Show the consumer owner on the consumer form

Shows the consumer's owner on the consumer add and edit forms, the way node shows "Authored by". Only users with administer consumer entities can change it.

Closes #3610995

Changes

  • Consumer::baseFieldDefinitions() gives owner_id the label "Owner", a description and an entity_reference_autocomplete form widget. The form display is configurable.
  • AccessControlHandler::checkFieldAccess() allows edit access to the owner field only with the admin permission. Core then hides the field from a user who only edits their own consumers, so their consumers stay theirs.

Update path

No update hook. The change affects form display options only, not field storage, so there are no pending entity updates. A saved form display gets the new widget on load. The kernel tests cover both.

Testing

  • ConsumerOwnerFieldTest (kernel): the label and description, the default and a saved form display, edit access by permission, and no pending entity updates.
  • ConsumerOwnerFormTest (functional): an administrator sees the Owner field and can change the owner. A user with update own consumer entities sees no Owner field, and their consumer keeps its owner.

To test by hand:

  1. Create a consumer as an administrator. The form has an Owner field.
  2. Change the owner to another user and save. Edit it again. The Owner field shows the new owner.
  3. Sign in as a user with only update own consumer entities and edit a consumer they own. The form has no Owner field.
Edited by Stuart Clark

Merge request reports

Loading
Loading