public function HighContrastConfigurationForm::buildForm in High contrast 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/ HighContrastConfigurationForm.php, line 81
Class
- HighContrastConfigurationForm
- Class HighContrastConfigurationForm.
Namespace
Drupal\high_contrast\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Form constructor.
$form = parent::buildForm($form, $form_state);
$config = $this
->config('high_contrast.settings');
$form['colors'] = [
'#type' => 'details',
'#title' => $this
->t('High contrast colors'),
'#open' => TRUE,
'#tree' => FALSE,
];
$form['colors']['colors_background'] = [
'#type' => 'color',
'#title' => $this
->t('Background'),
'#default_value' => $config
->get('colors_background'),
];
$form['colors']['colors_text'] = [
'#type' => 'color',
'#title' => $this
->t('Text'),
'#default_value' => $config
->get('colors_text'),
];
$form['colors']['colors_hyperlinks'] = [
'#type' => 'color',
'#title' => $this
->t('Hyperlinks'),
'#default_value' => $config
->get('colors_hyperlinks'),
];
if ($this->moduleHandler
->moduleExists('file')) {
$form['logo'] = [
'#type' => 'fieldset',
'#title' => $this
->t('High contrast logo image settings'),
];
$form['logo']['default_logo'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use the default logo (file named logo-hg in your theme folder if it exists)'),
'#default_value' => $config
->get('default_logo'),
'#tree' => FALSE,
'#description' => $this
->t('Check here if you want the theme to use the logo supplied with it.'),
];
$form['logo']['settings'] = [
'#type' => 'container',
'#states' => [
// Hide the logo settings when using the default logo.
'invisible' => [
'input[name="default_logo"]' => [
'checked' => TRUE,
],
],
],
];
$form['logo']['settings']['logo_path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Path to custom high contrast logo'),
'#description' => $this
->t('The path to the file you would like to use as your logo file instead of the default logo.'),
'#default_value' => $config
->get('logo_path'),
];
$form['logo']['settings']['logo_upload'] = [
'#type' => 'file',
'#title' => $this
->t('Upload high contrast logo image'),
'#maxlength' => 40,
'#description' => $this
->t("If you don't have direct file access to the server, use this field to upload your logo."),
];
}
return $form;
}