You are here

public function TextAlignment::buildStyleFormElements in Bootstrap Styles 1.0.x

Overrides StylePluginBase::buildStyleFormElements

File

src/Plugin/BootstrapStyles/Style/TextAlignment.php, line 52

Class

TextAlignment
Class TextAlignment.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function buildStyleFormElements(array &$form, FormStateInterface $form_state, $storage) {
  $form['text_alignment'] = [
    '#type' => 'radios',
    '#options' => $this
      ->getStyleOptions('text_alignment'),
    '#title' => $this
      ->t('Alignment'),
    '#default_value' => $storage['text_alignment']['class'] ?? NULL,
    '#validated' => TRUE,
    '#attributes' => [
      'class' => [
        'field-text-alignment',
        'bs_input-boxes',
      ],
    ],
  ];

  // Add icons to the container types.
  foreach ($form['text_alignment']['#options'] as $key => $value) {
    $form['text_alignment']['#options'][$key] = '<span class="input-icon ' . $key . '"></span>' . $value;
  }

  // Attach the Layout Builder form style for this plugin.
  $form['#attached']['library'][] = 'bootstrap_styles/plugin.text_alignment.layout_builder_form';
  return $form;
}