Problem/Motivation

The RoleAssign form widget is inserted to the user_register_form and user_form form ids, but not into custom form modes for the user entity.

Steps to reproduce

  1. Create a custom user form mode
  2. Attempt to create/edit a user using that form and an account that has the "assign roles" permission but not the "administer permissions" permission
  3. The roles options will not appear on the form.

Proposed resolution

Modify roleassign_form_alter() to check the entity type of the form, rather than the form id.

Issue fork roleassign-3213915

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hipp2bsquare created an issue. See original summary.

hipp2bsquare’s picture

I have pushed a fix up to the issue fork.

hipp2bsquare’s picture

Assigned: Unassigned » hipp2bsquare
hipp2bsquare’s picture

I'm going to make a new version of this patch for the 2.0.x branch.

hipp2bsquare’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

hipp2bsquare’s picture

Status: Active » Needs review

Please review MR !6, which supports custom user form modes on RoleAssign 2.0.x.

It identifies user form modes by checking the base form id. If the base form is the user form, then the form id is added to the $user_forms array:

if (($form_state->getBuildInfo()['base_form_id']) == 'user_form') {
      $user_forms[] = $form_id;
    }

I then made the user forms code the default case on the switch() statement.

hipp2bsquare’s picture

Assigned: hipp2bsquare » Unassigned
svendecabooter’s picture

Status: Needs review » Fixed

Looks good to me. Thanks for the MR!

svendecabooter’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.