public function UserDevelGenerate::settingsForm in Devel 8
Same name and namespace in other branches
- 8.3 devel_generate/src/Plugin/DevelGenerate/UserDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\UserDevelGenerate::settingsForm()
- 8.2 devel_generate/src/Plugin/DevelGenerate/UserDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\UserDevelGenerate::settingsForm()
- 4.x devel_generate/src/Plugin/DevelGenerate/UserDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\UserDevelGenerate::settingsForm()
Returns the form for the plugin.
Return value
array The array of default setting values, keyed by setting names.
Overrides DevelGenerateBase::settingsForm
File
- devel_generate/
src/ Plugin/ DevelGenerate/ UserDevelGenerate.php, line 80
Class
- UserDevelGenerate
- Provides a UserDevelGenerate plugin.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$form['num'] = array(
'#type' => 'number',
'#title' => $this
->t('How many users would you like to generate?'),
'#default_value' => $this
->getSetting('num'),
'#required' => TRUE,
'#min' => 0,
);
$form['kill'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Delete all users (except user id 1) before generating new users.'),
'#default_value' => $this
->getSetting('kill'),
);
$options = user_role_names(TRUE);
unset($options[DRUPAL_AUTHENTICATED_RID]);
$form['roles'] = array(
'#type' => 'checkboxes',
'#title' => $this
->t('Which roles should the users receive?'),
'#description' => $this
->t('Users always receive the <em>authenticated user</em> role.'),
'#options' => $options,
);
$form['pass'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Password to be set'),
'#default_value' => $this
->getSetting('pass'),
'#size' => 32,
'#description' => $this
->t('Leave this field empty if you do not need to set a password'),
);
$options = array(
1 => $this
->t('Now'),
);
foreach (array(
3600,
86400,
604800,
2592000,
31536000,
) as $interval) {
$options[$interval] = $this->dateFormatter
->formatInterval($interval, 1) . ' ' . $this
->t('ago');
}
$form['time_range'] = array(
'#type' => 'select',
'#title' => $this
->t('How old should user accounts be?'),
'#description' => $this
->t('User ages will be distributed randomly from the current time, back to the selected time.'),
'#options' => $options,
'#default_value' => 604800,
);
return $form;
}