Commit 9f208e6f authored by xjm's avatar xjm

Issue #2049921 by jibran, tim.plunkett: Update the markup in UserMultipleCancelConfirm::buildForm()

parent c87ebca4
......@@ -96,6 +96,7 @@ public function getConfirmText() {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// Retrieve the accounts to be canceled from the temp store.
/* @var \Drupal\user\Entity\User[] $accounts */
$accounts = $this->tempStoreFactory
->get('user_user_operations_cancel')
->get($this->currentUser()->id());
......@@ -104,22 +105,27 @@ public function buildForm(array $form, FormStateInterface $form_state) {
}
$root = NULL;
$form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
$names = [];
$form['accounts'] = ['#tree' => TRUE];
foreach ($accounts as $account) {
$uid = $account->id();
$names[$uid] = $account->label();
// Prevent user 1 from being canceled.
if ($uid <= 1) {
$root = intval($uid) === 1 ? $account : $root;
continue;
}
$form['accounts'][$uid] = array(
$form['accounts'][$uid] = [
'#type' => 'hidden',
'#value' => $uid,
'#prefix' => '<li>',
'#suffix' => $account->label() . "</li>\n",
);
];
}
$form['account']['names'] = [
'#theme' => 'item_list',
'#items' => $names,
];
// Output a notice that user 1 cannot be canceled.
if (isset($root)) {
$redirect = (count($accounts) == 1);
......
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