Same name and namespace in other branches
  1. 7.x modules/system/theme.api.php \hook_form_system_theme_settings_alter()
  2. 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_form_system_theme_settings_alter()
  3. 9 core/lib/Drupal/Core/Render/theme.api.php \hook_form_system_theme_settings_alter()

Allow themes to alter the theme-specific settings form.

With this hook, themes can alter the theme-specific settings form in any way allowable by Drupal's Form API, such as adding form elements, changing default values and removing form elements. See the Form API documentation on api.drupal.org for detailed information.

Note that the base theme's form alterations will be run before any sub-theme alterations.

Parameters

$form: Nested array of form elements that comprise the form.

$form_state: The current state of the form.

Related topics

3 functions implement hook_form_system_theme_settings_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

olivero_form_system_theme_settings_alter in core/themes/olivero/theme-settings.php
Implements hook_form_FORM_ID_alter() for system_theme_settings.
test_theme_settings_form_system_theme_settings_alter in core/modules/system/tests/themes/test_theme_settings/theme-settings.php
Implements hook_form_system_theme_settings_alter().
test_theme_theme_form_system_theme_settings_alter in core/modules/system/tests/themes/test_theme_theme/test_theme_theme.theme
Implements hook_form_system_theme_settings_alter().

File

core/lib/Drupal/Core/Render/theme.api.php, line 532
Hooks and documentation related to the theme and render system.

Code

function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {

  // Add a checkbox to toggle the breadcrumb trail.
  $form['toggle_breadcrumb'] = [
    '#type' => 'checkbox',
    '#title' => t('Display the breadcrumb'),
    '#default_value' => theme_get_setting('features.breadcrumb'),
    '#description' => t('Show a trail of links from the homepage to the current page.'),
  ];
}