Unverified Commit 90897afe authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3099026 by mherchel, lauriii, bartlangelaan, timohuisman,...

Issue #3099026 by mherchel, lauriii, bartlangelaan, timohuisman, pradhumanjainOSL, hctom, jwilson3, smustgrave: Claro's preprocessing of field multiple value form's table header cell removes potential changes by others
parent 66500ab0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1608,9 +1608,10 @@ function template_preprocess_field_multiple_value_form(&$variables) {
    $header = [
      [
        'data' => [
          '#prefix' => '<h4' . $header_attributes . '>',
          '#markup' => $element['#title'],
          '#suffix' => '</h4>',
          '#type' => 'html_tag',
          '#tag' => 'h4',
          '#value' => $element['#title'],
          '#attributes' => $header_attributes,
        ],
        'colspan' => 2,
        'class' => ['field-label'],
+5 −19
Original line number Diff line number Diff line
@@ -993,27 +993,13 @@ function claro_preprocess_field_multiple_value_form(&$variables) {
  $variables['disabled'] = !empty($variables['element']['#disabled']);

  if ($variables['multiple']) {
    // Add an additional CSS class for the field label table cell.
    // This repeats the logic of template_preprocess_field_multiple_value_form()
    // without using '#prefix' and '#suffix' for the wrapper element.
    //
    // If the field is multiple, we don't have to check the existence of the
    // table header cell.
    //
    // Add an additional CSS class to the field label table cell. The table
    // header cell should always exist unless removed by contrib.
    // @see template_preprocess_field_multiple_value_form().
    $header_attributes = ['class' => ['form-item__label', 'form-item__label--multiple-value-form']];
    if (!empty($variables['element']['#required'])) {
      $header_attributes['class'][] = 'js-form-required';
      $header_attributes['class'][] = 'form-required';
    }
    // Using array_key_first() for addressing the first header cell would be
    // more elegant here, but we can rely on the related theme.inc preprocess.
    $variables['table']['#header'][0]['data'] = [
      '#type' => 'html_tag',
      '#tag' => 'h4',
      '#value' => $variables['element']['#title'],
      '#attributes' => $header_attributes,
    ];
    if (isset($variables['table']['#header'][0]['data']['#attributes'])) {
      $variables['table']['#header'][0]['data']['#attributes']->removeClass('label');
      $variables['table']['#header'][0]['data']['#attributes']->addClass('form-item__label', 'form-item__label--multiple-value-form');
    }

    if ($variables['disabled']) {
      $variables['table']['#attributes']['class'][] = 'tabledrag-disabled';
+6 −1
Original line number Diff line number Diff line
@@ -49,9 +49,14 @@ tr .form-item,
  line-height: var(--line-height-form-label);
}

.form-item__label--multiple-value-form {
/* Multiple selectors used to ensure styling even if modules override markup. */

.form-item__label--multiple-value-form,
.field-multiple-table .field-label h4.label {
  display: inline-block;
  margin-top: 0;
  margin-bottom: 0;
  vertical-align: middle;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
+5 −1
Original line number Diff line number Diff line
@@ -37,9 +37,13 @@ tr .form-item,
  font-weight: bold;
  line-height: var(--line-height-form-label);
}
.form-item__label--multiple-value-form {
/* Multiple selectors used to ensure styling even if modules override markup. */
.form-item__label--multiple-value-form,
.field-multiple-table .field-label h4.label {
  display: inline-block;
  margin-top: 0;
  margin-bottom: 0;
  vertical-align: middle;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;