class FieldMultipleValueForm

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

Plugin annotation

@BootstrapPreprocess("field_multiple_value_form")

Hierarchy

Expanded class hierarchy of FieldMultipleValueForm

Related topics

Namespace

Drupal\bootstrap\Plugin\Preprocess
Source
class FieldMultipleValueForm extends PreprocessBase implements PreprocessInterface {

  /**
   * {@inheritdoc}
   */
  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;
    }
  }

}

Members

Contains filters are case sensitive
Name Modifiers Type Description
FieldMultipleValueForm::preprocessElement public function Preprocess the variables array if an element is present. Overrides PreprocessBase::preprocessElement
PluginBase::$theme protected property The currently set theme object.
PluginBase::__construct public function
PreprocessBase::$hook protected property The theme hook invoked.
PreprocessBase::$info protected property The theme hook info array from the theme registry.
PreprocessBase::$variables protected property The Variables object.
PreprocessBase::preprocess public function Preprocess theme hook variables. Overrides PreprocessInterface::preprocess
PreprocessBase::preprocessAttributes protected function Ensures all attributes have been converted to an Attribute object.
PreprocessBase::preprocessDescription protected function Converts any set description variable into a traversable array.
PreprocessBase::preprocessVariables protected function Preprocess the variables array.