Reputation: 2673
I want to display a form having checkboxes against every user role I have this
$roles = user_roles($membersonly = FALSE, $permission = NULL);
$form['trc_user_roles'] = array(
'#type' => 'chekboxes',
'#title' => 'Allow users who can see uploaded files',
'#options' => $roles,
'#descripion' => 'User roles checked are able to see site-wide uploads.'
);
return system_settings_form($form);
The output is a blank page.
Upvotes: 0
Views: 418
Reputation: 36956
You have a syntax error in your call to user_roles()
and a spelling error ('chekboxes'). Try this:
$roles = user_roles(FALSE, NULL);
$form['trc_user_roles'] = array(
'#type' => 'checkboxes',
'#title' => 'Allow users who can see uploaded files',
'#options' => $roles,
'#descripion' => 'User roles checked are able to see site-wide uploads.',
'#default_value' => variable_get('trc_user_roles', array())
);
return system_settings_form($form);
I've also added a #default_value
attribute so the next time you re-load the form the selected options will be pre-filled in.
Upvotes: 2