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