This module enforces mutual exclusion between configured groups of (Flag module) flags on the same entity. When a user sets one flag in a group of flags on an entity, the remaining flags are unset.
Features
The Flag module does not natively enforce mutual exclusion among flags. This module adds that capability by listening to Flag's ENTITY_FLAGGED event and automatically unsets the counterpart flags when one flag in a configured group is set.
Common use case:
- like/dislike reactions (group of two flags) where a user can hold only one at a time. Any number of groups can be configured, across any entity types and any flags that Flag supports.
- multiple choice settings (groups of multiple flags) where a user can select only one selection at a time. Up to 10 flags can be configured in a group. Common examples might be: subscription levels on a member plan, multiple choice options on an exam, user polls
Post-installation instructions are summarized below, additional documentation is contained in the module’s README file.
Breaking change (Release 1.1.x) : prior to this release, the module used a “pairs" model (exactly two flags per rule, stored under a pairs config key). This release replaces pairs entirely with a groups model (2-10 flags per rule, stored under a groups config key). Existing pair configuration is automatically migrated to groups the next time you run database updates — see "Upgrading from 1.0” in the README.
Post-Installation
1. Navigate to Administration → Structure → Flags (/admin/structure/flags) and add the flags that are intended to work as a mutually exclusive group. Make a note of their names, and the entity type to which they're configured to apply.
2. Navigate to Configuration → Content authoring → Flag mutually exclusive
(/admin/config/content/flag-mutually-exclusive) and click Add group.
Configuration is exported as part of flag_mutually_exclusive.settings and
is included in drush config:export / drush config:import deployments.
| Setting | Description |
|---|---|
| Label | Human-readable name for the group, e.g. "Like / Dislike" |
| Machine name | Unique identifier, auto-generated from the label |
| Entity type | Machine name of the entity type all flags in the group apply to |
| Flags | 2 to 10 flags — setting any one unsets all the others in the group. The list refreshes via AJAX to show only flags compatible with the selected entity type, and a counter shows how many are currently selected. |
| Enabled | Uncheck to temporarily disable without deleting |
Configuration is exported as part of flag_mutually_exclusive.settings`and
is included in drush config:export / drush config:import deployments.
Additional Requirements
- Drupal ^11.3
- flag:flag (>=5.0.0)
Similar projects
Rules can be used to configure this functionality. However Rules is heavyweight, this module targets a specific set of functionality that managed Flags on entities in a specific manner, and provides that functionality without the overhead of Rules.
Supporting this Module
This module is supported by Lisa Harrison (lisa.rae), an individual contributor and long-time member of the Drupal community.
Project information
- Project categories: Automation, Content editing experience, User engagement
- Ecosystem: Flag, Chirp
2 sites report using this module
- Created by lisa.rae on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Now supports 2 to 10 flags, also fixes bugs identified in 1.1.x-dev version testing
Development version: 1.1.x-dev updated 26 Jul 2026 at 13:46 UTC
