function claro_preprocess_details

Same name in other branches
  1. 9 core/themes/claro/claro.theme \claro_preprocess_details()
  2. 10 core/themes/claro/claro.theme \claro_preprocess_details()
  3. 11.x core/themes/claro/claro.theme \claro_preprocess_details()

Implements hook_preprocess_HOOK() for details.

@todo Revisit when https://www.drupal.org/node/3056089 is in.

File

core/themes/claro/claro.theme, line 326

Code

function claro_preprocess_details(&$variables) {
    $element = $variables['element'];
    if (!empty($element['#accordion_item'])) {
        // Details should appear as an accordion item.
        $variables['accordion_item'] = TRUE;
    }
    if (!empty($element['#accordion'])) {
        // Details should appear as a standalone accordion.
        $variables['accordion'] = TRUE;
    }
    if (!empty($element['#theme']) && $element['#theme'] === 'file_widget_multiple') {
        // Mark the details required if needed. If the file widget allows uploading
        // multiple files, the required state is checked by checking the state of
        // the first child.
        $variables['required'] = isset($element[0]['#required']) ? $element[0]['#required'] : !empty($element['#required']);
        // If the error is the same as the one in the multiple field widget element,
        // we have to avoid displaying it twice. Seven and Stark have this issue
        // as well.
        // @todo revisit when https://www.drupal.org/node/3084906 is fixed.
        if (isset($element['#errors']) && isset($variables['errors']) && $element['#errors'] === $variables['errors']) {
            unset($variables['errors']);
        }
    }
    $variables['disabled'] = !empty($element['#disabled']);
}

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