public function RoleWatchdogSettingsForm::buildForm in Role Watchdog 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/ RoleWatchdogSettingsForm.php, line 32
Class
- RoleWatchdogSettingsForm
- Class RoleWatchdogSettingsForm.
Namespace
Drupal\role_watchdog\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('role_watchdog.settings');
$form['email'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Email Settings'),
'#description' => $this
->t('Role watchdog can monitor one or more roles for changes and notify members of selected roles via email whenever a change occurs. At least one Monitor and one Notify role must be selected for this functionality.'),
];
$roles = user_roles($membersonly = TRUE);
foreach ($roles as $key => $value) {
$roles_options[$key] = $value
->get('label');
}
$form['email']['role_watchdog_monitor_roles'] = [
'#type' => 'select',
'#title' => $this
->t('Monitor for change'),
'#options' => $roles_options,
'#default_value' => $config
->get('role_watchdog_monitor_roles') != NULL ? $config
->get('role_watchdog_monitor_roles') : NULL,
'#description' => $this
->t('Select roles to monitor for change.'),
'#multiple' => TRUE,
];
$form['email']['role_watchdog_notify_email'] = [
'#type' => 'email',
'#title' => $this
->t('Notify email on role change.'),
'#default_value' => $config
->get('role_watchdog_notify_email') != NULL ? $config
->get('role_watchdog_notify_email') : NULL,
'#description' => $this
->t('Email address to notify on change. Leave it blank in case notifications aren\'t needed.'),
];
return parent::buildForm($form, $form_state);
}