function FormHooks::formSystemThemeSettingsAlter
Same name and namespace in other branches
- 11.x core/themes/admin/src/Hook/FormHooks.php \Drupal\admin\Hook\FormHooks::formSystemThemeSettingsAlter()
Implement hook form_system_theme_settings_alter().
Attributes
#[Hook('form_system_theme_settings_alter')]
File
-
core/
themes/ admin/ src/ Hook/ FormHooks.php, line 372
Class
- FormHooks
- Provides form related hook implementations.
Namespace
Drupal\admin\HookCode
public function formSystemThemeSettingsAlter(array &$form) : void {
if (!isset($form['config_key']['#value']) || $form['config_key']['#value'] !== 'admin.settings') {
return;
}
$settings = Settings::getInstance();
// Move default theme settings to bottom.
$form['logo']['#open'] = FALSE;
$form['logo']['#weight'] = 97;
$form['favicon']['#open'] = FALSE;
$form['favicon']['#weight'] = 98;
$form['theme_settings']['#open'] = FALSE;
$form['theme_settings']['#weight'] = 99;
// General settings.
$form['custom_settings'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this->t('Settings'),
] + $settings->getSettingsForm();
// Allow user settings.
$form['custom_settings']['show_user_theme_settings'] = [
'#type' => 'checkbox',
'#title' => $this->t('Users can override admin settings'),
'#description' => $this->t('Expose the admin theme settings to users.'),
'#default_value' => $settings->getDefault('show_user_theme_settings'),
];
// Add handler.
$form['#validate'][] = [
__CLASS__,
'formSystemThemeSettingsAlterValidate',
];
$form['#submit'][] = [
__CLASS__,
'formSystemThemeSettingsAlterSubmit',
];
// Attach custom library.
$form['#attached']['library'][] = 'admin/settings';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.