public function BackgroundColor::buildStyleFormElements in Bootstrap Styles 1.0.x
Overrides StylePluginBase::buildStyleFormElements
File
- src/
Plugin/ BootstrapStyles/ Style/ BackgroundColor.php, line 67
Class
- BackgroundColor
- Class BackgroundColor.
Namespace
Drupal\bootstrap_styles\Plugin\BootstrapStyles\StyleCode
public function buildStyleFormElements(array &$form, FormStateInterface $form_state, $storage) {
$icon_path = drupal_get_path('module', 'bootstrap_styles') . '/images/';
$form['background_type']['#options']['color'] = $this
->getSvgIconMarkup($icon_path . 'plugins/background/background-color.svg');
$form['background_type']['#default_value'] = $storage['background']['background_type'] ?? 'color';
$form['background_color'] = [
'#type' => 'radios',
'#options' => $this
->getStyleOptions('background_colors'),
'#title' => $this
->t('Background color'),
'#default_value' => $storage['background_color']['class'] ?? NULL,
'#validated' => TRUE,
'#attributes' => [
'class' => [
'field-background-color',
'bs_input-circles',
'with-selected-gradient',
],
],
'#states' => [
'visible' => [
':input.bs_background--type' => [
'value' => 'color',
],
],
],
];
// Responsive.
$this
->createBreakpointsStyleFormFields($form, 'background_color', 'background', $storage, 'background_colors');
// Attach the Layout Builder form style for this plugin.
$form['#attached']['library'][] = 'bootstrap_styles/plugin.background_color.layout_builder_form';
return $form;
}