Commit 945ed201 authored by alexpott's avatar alexpott

Issue #119038 by Pancho, ximo, stefank: Code cleanup: 'authenticated users' role.

parent 18ddb004
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment