function PreprocessHooks::preprocessDescriptionToggle

Same name and namespace in other branches
  1. 11.x core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::preprocessDescriptionToggle()

Generic preprocess enabling toggle.

Parameters

array $variables: The variables array (modify in place).

File

core/themes/admin/src/Hook/PreprocessHooks.php, line 1511

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\admin\Hook

Code

private function preprocessDescriptionToggle(array &$variables) : void {
  $isEnabled = Settings::getInstance()->get('show_description_toggle') && Helper::isContentForm();
  if (isset($variables['element']['#description_toggle']) && $variables['element']['#description_toggle'] || $isEnabled) {
    if (!empty($variables['description'])) {
      $variables['description_display_toggle'] = $variables['description_display'] ?? 'after';
      $variables['description_display'] = 'invisible';
      $variables['description_toggle'] = TRUE;
    }
    elseif (!empty($variables['element']['#description_toggle'])) {
      $variables['description_toggle'] = TRUE;
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.