Ability to alter the Dropdown widget

Created on 20 March 2023, over 2 years ago
Updated 11 May 2023, over 2 years ago

Problem/Motivation

Unable to restrict the User entity reference field result by role. All users are listed irrespective of Field storage settings.

Steps to reproduce

1. Create any User reference field into any Content type.
2. Under the entity reference, field storage restrict user by role.
3. Create a view for the content type.
4. Add the user entity reference field into the views exposed filter.
5. Choose "Views Entity Reference Filter" for the user reference field.
6. All users are listed instead of Role-based restrictions.

Proposed resolution

Ability to add the option to alter the result loaded from the Dropdown list.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India arunkumark Coimbatore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arunkumark
  • @arunkumark opened merge request.
  • 🇮🇳India arunkumark Coimbatore

    With help of the MR !4, We can able to alter the results of the Entity select list.

    /**
     * Implements hook_verf_entites_options_alter().
     */
    function example_verf_entites_options_alter(&$referenceable_entities) {
      foreach ($referenceable_entities as $key => $entites) {
        if (!$entites->hasRole('administrator')) {
          unset($referenceable_entities[$key]);
        }
      }
    }
  • Status changed to Needs review over 2 years ago
  • First commit to issue fork.
  • Status changed to Fixed over 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024