Whitelist/Blacklist

Created on 21 July 2025, about 1 month ago

How we can whitelist or blacklist items from selection?

My current code looks like this:

$form['field_allowed_viewers'] = [
      '#type' => 'entity_autocomplete_tagify',
      '#target_type' => 'user',
      '#title' => $this->t('Grant Access To'),
      '#description' => $this->t('Users who can view this private gallery (besides you).'),
      '#tags' => TRUE,
      '#max_items' => 20,
      '#selection_handler' => 'default:user',
      '#selection_settings' => [
        'include_anonymous' => FALSE,
      ],
    ];

Tried different approaches:

'#selection_settings' => ['blacklist' => $uids] or ['whitelist' => $uids]

but unfortunatelly nothing works. Any suggestions?

💬 Support request
Status

Active

Version

1.2

Component

Code

Created by

🇩🇪Germany killah89 Schneverdingen

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

Comments & Activities

Production build 0.71.5 2024