public function RealnameAdminSettingsForm::buildForm in Real Name 2.x
Same name and namespace in other branches
- 8 src/Form/RealnameAdminSettingsForm.php \Drupal\realname\Form\RealnameAdminSettingsForm::buildForm()
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/ RealnameAdminSettingsForm.php, line 30
Class
- RealnameAdminSettingsForm
- Configure Realname settings for this site.
Namespace
Drupal\realname\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('realname.settings');
$form['general'] = [
'#type' => 'fieldset',
'#title' => $this
->t('General settings'),
];
$note = '<div>';
$note .= $this
->t('Note that if it is changed, all current Realnames will be deleted and the list in the database will be rebuilt as needed.');
$note .= '</div>';
$form['general']['realname_pattern'] = [
'#type' => 'textfield',
'#title' => $this
->t('Realname pattern'),
'#default_value' => $config
->get('pattern'),
'#element_validate' => [
'token_element_validate',
],
'#token_types' => [
'user',
],
'#min_tokens' => 1,
'#required' => TRUE,
'#maxlength' => 256,
'#description' => $this
->t('This pattern will be used to construct Realnames for all users.') . $note,
];
// Add the token tree UI.
$form['general']['token_help'] = [
'#theme' => 'token_tree_link',
'#token_types' => [
'user',
],
'#global_types' => FALSE,
];
return parent::buildForm($form, $form_state);
}