feat: #3112680 Offer new terms only to a user who may create them

Issue: https://www.drupal.org/project/autocomplete_deluxe/issues/3112680

Follows what Daveiano and Cyberwolf proposed on the issue: no new permission of our own, the widget asks the access handler of the referenced entity type whether the current user may create an entity in the autocreate bundle. For taxonomy that is the core create terms in <vocabulary> permission, and any module that alters entity access is respected as well.

  • The entity type manager is injected into the widget.
  • New terms are offered only when the widget setting is on, an autocreate bundle is configured, and the create access check passes for the current user.
  • The autocreate information is set from the same result, so the JavaScript and the form validation agree.

Tested on Drupal 11.4 with an unlimited term reference field, a role without create terms in topics: the widget reports new_terms: false and pressing Enter adds nothing and creates no term. After granting the permission to that same role, the same user adds Allowed New Topic and the node saves with the new term.

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading