Form mode permissions lack config dependencies, causing invalid permission errors after config import

Created on 13 May 2025, 4 months ago

Problem/Motivation

When installing a site from existing configuration (e.g., via configuration sync or a distribution), roles with form_mode_control permissions (e.g., "Use the form mode X linked to node entity Y") trigger errors like:

Non-existent permission(s) assigned to role "editor" (editor) were removed. Invalid permission(s): use The form mode my_form_mode linked to node entity( article ).

This happens because those dynamically-generated permissions are missing proper dependencies on their associated core.entity_form_display configs. As a result, if the form display config isn't present, due to config import order for example, Drupal can't cleanly manage the permission.

Steps to reproduce

  1. Install form_mode_control module and create custom form modes.
  2. Assign the generated form mode permissions to a role.
  3. Export config.
  4. Import config in a clean install.
  5. Observe warnings about invalid permissions removed from roles.

Proposed resolution

  1. Add a 'dependencies' => ['config' => ['core.entity_form_display.X.Y.Z']] entry for each form mode permission in roleToFormMode().
  2. Provide a hook_update_N() implementation to trigger recalculating role config dependencies for existing sites.
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024