You are here

public function CdnJsdelivrTheme::alterFormElement in Express 8

The alter method to store the code.

Parameters

\Drupal\bootstrap\Utility\Element $form: The Element object that comprises the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

string $form_id: String representing the name of the form itself. Typically this is the name of the function that generated the form.

Overrides CdnProvider::alterFormElement

File

themes/contrib/bootstrap/src/Plugin/Setting/Advanced/Cdn/CdnJsdelivrTheme.php, line 40
Contains \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnJsdelivrTheme.

Class

CdnJsdelivrTheme
The "cdn_jsdelivr_theme" theme setting.

Namespace

Drupal\bootstrap\Plugin\Setting\Advanced\Cdn

Code

public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  $setting = $this
    ->getSettingElement($form, $form_state);
  $themes = $this->provider
    ->getThemes();
  $version = $form_state
    ->getValue('cdn_jsdelivr_version', $this->theme
    ->getSetting('cdn_jsdelivr_version'));
  $setting
    ->setProperty('suffix', '<div id="bootstrap-theme-preview"></div>');
  $setting
    ->setProperty('description', t('Choose the example <a href=":bootstrap_theme" target="_blank">Bootstrap Theme</a> provided by Bootstrap or one of the many, many <a href=":bootswatch" target="_blank">Bootswatch</a> themes!', [
    ':bootswatch' => 'https://bootswatch.com',
    ':bootstrap_theme' => 'http://getbootstrap.com/examples/theme/',
  ]));
  $options = [];
  if (isset($themes[$version])) {
    foreach ($themes[$version] as $theme => $data) {
      $options[$theme] = $data['title'];
    }
  }
  $setting
    ->setProperty('options', $options);
}