file FieldMultipleValueForm.php

Namespace

Drupal\bootstrap\Plugin\Preprocess
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Preprocess;
  3. use Drupal\bootstrap\Utility\Element;
  4. use Drupal\bootstrap\Utility\Variables;
  5. /**
  6. * Pre-processes variables for the "field_multiple_value_form" theme hook.
  7. *
  8. * @ingroup plugins_preprocess
  9. *
  10. * @BootstrapPreprocess("field_multiple_value_form")
  11. */
  12. class FieldMultipleValueForm extends PreprocessBase implements PreprocessInterface {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function preprocessElement(Element $element, Variables $variables) {
  17. // Wrap header columns in label element for Bootstrap.
  18. if ($variables['multiple']) {
  19. $header = [
  20. [
  21. 'data' => [
  22. '#prefix' => '<label class="label">',
  23. 'title' => ['#markup' => $element->getProperty('title')],
  24. '#suffix' => '</label>',
  25. ],
  26. 'colspan' => 2,
  27. 'class' => [
  28. 'field-label',
  29. !empty($element['#required']) ? 'form-required' : '',
  30. ],
  31. ],
  32. t('Order', [], ['context' => 'Sort order']),
  33. ];
  34. $variables['table']['#header'] = $header;
  35. }
  36. }
  37. }

Classes

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