function public function FieldMultipleValueForm::preprocessElement

8.x-3.x FieldMultipleValueForm.php public FieldMultipleValueForm::preprocessElement(Element $element, Variables $variables)

Preprocess the variables array if an element is present.

Parameters

\Drupal\bootstrap\Utility\Element $element: The Element object.

\Drupal\bootstrap\Utility\Variables $variables: The Variables object.

Overrides PreprocessBase::preprocessElement

Class

FieldMultipleValueForm
Pre-processes variables for the "field_multiple_value_form" theme hook.

Namespace

Drupal\bootstrap\Plugin\Preprocess

Source src/Plugin/Preprocess/FieldMultipleValueForm.php (line 20)

public function preprocessElement(Element $element, Variables $variables) {
  // Wrap header columns in label element for Bootstrap.
  if ($variables['multiple']) {
    $header = [
      [
        'data' => [
          '#prefix' => '<label class="label">',
          'title' => ['#markup' => $element->getProperty('title')],
          '#suffix' => '</label>',
        ],
        'colspan' => 2,
        'class' => [
          'field-label',
          !empty($element['#required']) ? 'form-required' : '',
        ],
      ],
      t('Order', [], ['context' => 'Sort order']),
    ];

    $variables['table']['#header'] = $header;
  }
}