You are here

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

Create breakpoint field for a given field.

Parameters

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

string $field_name: The field name.

string $breakpoint_key: The breakpoint key.

string $group_id: The plugin group id.

array $storage: An associative array containing the form storage.

string $storage_key: The storage key of the field in the storage array if it's different from the field name.

1 call to ResponsiveTrait::createBreakpointStyleFormField()
ResponsiveTrait::createBreakpointsStyleFormFields in src/ResponsiveTrait.php
Create breakpoints fields for a given field.

File

src/ResponsiveTrait.php, line 204

Class

ResponsiveTrait
A Trait for responsive methods.

Namespace

Drupal\bootstrap_styles

Code

protected function createBreakpointStyleFormField(array &$form, string $field_name, string $breakpoint_key, string $group_id, array $storage, string $storage_key = NULL) {
  $form[$field_name . '_' . $breakpoint_key] = $form[$field_name];
  $form[$field_name . '_' . $breakpoint_key]['#options'] = $this
    ->getStyleOptions($storage_key . '_' . $breakpoint_key);
  $form[$field_name . '_' . $breakpoint_key]['#default_value'] = $storage[$field_name . '_' . $breakpoint_key]['class'] ?? NULL;
  $form[$field_name . '_' . $breakpoint_key]['#validated'] = TRUE;
  $form[$field_name . '_' . $breakpoint_key]['#states']['visible'][':input.bs_responsive_' . $group_id]['value'] = $breakpoint_key;

  // Hide the generic one.
  $form[$field_name]['#states']['visible'][':input.bs_responsive_' . $group_id]['value'] = 'all';
}