You are here

protected function ResponsiveTrait::buildBreakpointsConfigurationForm in Bootstrap Styles 1.0.x

TODO: Remove and replace this function.

Build the breakpoints configuration form.

Parameters

array $form: An associative array containing the structure of the form.

array $fields: The array of fields, each field has its parents and keyed by field name.

2 calls to ResponsiveTrait::buildBreakpointsConfigurationForm()
BackgroundColor::buildConfigurationForm in src/Plugin/BootstrapStyles/Style/BackgroundColor.php
TextColor::buildConfigurationForm in src/Plugin/BootstrapStyles/Style/TextColor.php

File

src/ResponsiveTrait.php, line 150

Class

ResponsiveTrait
A Trait for responsive methods.

Namespace

Drupal\bootstrap_styles

Code

protected function buildBreakpointsConfigurationForm(array &$form, array $fields) {

  // Loop through the fields.
  foreach ($fields as $field_name => $parents) {

    // Loop through the breakpoints.
    foreach ($this
      ->getBreakpoints() as $breakpoint_key => $breakpoint_value) {

      // Get the original field.
      $field = NestedArray::getValue($form, array_merge($parents, [
        $field_name,
      ]));

      // Change field attributes.
      $field['#title'] .= ' - ' . $breakpoint_value;
      $field['#default_value'] = $this
        ->config()
        ->get($field_name . '_' . $breakpoint_key);
      NestedArray::setValue($form, array_merge($parents, [
        $field_name . '_' . $breakpoint_key,
      ]), $field);
    }
  }
}