Closed (duplicate)
Project:
Admin role
Version:
5.x-1.5
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2008 at 15:42 UTC
Updated:
26 Sep 2008 at 17:27 UTC
You are using array_merge in:
function adminrole_admin_settings() {
$form = array();
$u_roles = user_roles();
ksort($u_roles);
$form['adminrole_adminrole'] = array(
'#type' => 'select',
'#title' => t('Admin Roles'),
'#default_value' => variable_get('adminrole_adminrole', 0),
'#description' => t("Which Role is Admin?"),
'#options' => array_merge(array(0 => t('-- Please Select One --')), $u_roles),
);
return system_settings_form($form);
}
But it's really buggy, because array_merge will rewrite the array indexes starting from 0, delinking the name to the real RID.
You have to use only the + operator, a simple concatenation, to preserve the indexes, like this:
function adminrole_admin_settings() {
$form = array();
$u_roles = user_roles();
$form['adminrole_adminrole'] = array(
'#type' => 'select',
'#title' => t('Admin Roles'),
'#default_value' => variable_get('adminrole_adminrole', 0),
'#description' => t("Which Role is Admin?"),
'#options' => (array('-- Please Select One --') + $u_roles),
);
return system_settings_form($form);
}
We don't need the ksort call, because the Selection text wil be ever 0, so the first item
Comments
Comment #1
marcingy commentedhttp://drupal.org/node/300872