public function RoleAssignAdminForm::buildForm in RoleAssign 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ RoleAssignAdminForm.php, line 31
Class
- RoleAssignAdminForm
- Configure book settings for this site.
Namespace
Drupal\roleassign\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get all available roles except for
// 'anonymous user' and 'authenticated user'.
$roles = user_role_names(TRUE);
unset($roles[RoleInterface::AUTHENTICATED_ID]);
// Show checkboxes with roles that can be delegated if any.
if ($roles) {
$config = $this
->config('roleassign.settings');
$form['roleassign_roles'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Roles'),
'#default_value' => $config
->get('roleassign_roles'),
'#options' => $roles,
'#description' => $this
->t('Select roles that should be available for assignment.'),
];
}
return parent::buildForm($form, $form_state);
}