diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index c9451a6c32fc24c595ab6467b6b58ed460c0224e..5a8fe2e2b5070bf4855e17a76d113e8cdd511ad6 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -195,18 +195,6 @@ public function form(array $form, FormStateInterface $form_state) { ); $roles = array_map(array('\Drupal\Component\Utility\String', 'checkPlain'), user_role_names(TRUE)); - // The disabled checkbox subelement for the 'authenticated user' role - // must be generated separately and added to the checkboxes element, - // because of a limitation in Form API not supporting a single disabled - // checkbox within a set of checkboxes. - // @todo This should be solved more elegantly. See issue #119038. - $checkbox_authenticated = array( - '#type' => 'checkbox', - '#title' => $roles[DRUPAL_AUTHENTICATED_RID], - '#default_value' => TRUE, - '#disabled' => TRUE, - ); - unset($roles[DRUPAL_AUTHENTICATED_RID]); $form['account']['roles'] = array( '#type' => 'checkboxes', @@ -214,7 +202,12 @@ public function form(array $form, FormStateInterface $form_state) { '#default_value' => (!$register ? $account->getRoles() : array()), '#options' => $roles, '#access' => $roles && $user->hasPermission('administer permissions'), - DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated, + ); + + // Special handling for the inevitable "Authenticated user" role. + $form['account']['roles'][DRUPAL_AUTHENTICATED_RID] = array( + '#default_value' => TRUE, + '#disabled' => TRUE, ); $form['account']['notify'] = array(