Skip to content

Instantly share code, notes, and snippets.

@calvez
Created October 12, 2018 15:04
Show Gist options
  • Save calvez/d528985066de18c782b3e0caf9a26dfc to your computer and use it in GitHub Desktop.
Save calvez/d528985066de18c782b3e0caf9a26dfc to your computer and use it in GitHub Desktop.
// If the paragraph type has got a background color field.
if (isset($element['subform']['bp_background']) && isset($element['subform']['bp_background']['widget'])) {
$configFactory = \Drupal::configFactory()->getEditable('varbase_bootstrap_paragraphs.settings');
$background_colors = $configFactory->get('background_colors');
$background_colors_options = ['_none' => t('N/A')];
$lines = explode(PHP_EOL, $background_colors);
foreach($lines as $line) {
$line = explode('|', $line);
$background_colors_options[$line[0]] = $line[1];
}
// Updated the bp_background options with the list of vbp colors.
$element['subform']['bp_background']['widget']['#options'] = $background_colors_options;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment