public function CdnProvider::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 SettingBase::alterFormElement
2 methods override CdnProvider::alterFormElement()
- CdnJsdelivrTheme::alterFormElement in themes/
contrib/ bootstrap/ src/ Plugin/ Setting/ Advanced/ Cdn/ CdnJsdelivrTheme.php - The alter method to store the code.
- CdnJsdelivrVersion::alterFormElement in themes/
contrib/ bootstrap/ src/ Plugin/ Setting/ Advanced/ Cdn/ CdnJsdelivrVersion.php - The alter method to store the code.
File
- themes/
contrib/ bootstrap/ src/ Plugin/ Setting/ Advanced/ Cdn/ CdnProvider.php, line 70 - Contains \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnProvider.
Class
- CdnProvider
- The "cdn_provider" theme setting.
Namespace
Drupal\bootstrap\Plugin\Setting\Advanced\CdnCode
public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
// Retrieve the provider from form values or the setting.
$default_provider = $form_state
->getValue('cdn_provider', $this->theme
->getSetting('cdn_provider'));
$group = $this
->getGroupElement($form, $form_state);
$group
->setProperty('description', '<div class="alert alert-info messages warning"><strong>' . t('NOTE') . ':</strong> ' . t('Using one of the "CDN Provider" options below is the preferred method for loading Bootstrap CSS and JS on simpler sites that do not use a site-wide CDN. Using a "CDN Provider" for loading Bootstrap, however, does mean that it depends on a third-party service. There is no obligation or commitment by these third-parties that guarantees any up-time or service quality. If you need to customize Bootstrap and have chosen to compile the source code locally (served from this site), you must disable the "CDN Provider" option below by choosing "- None -" and alternatively enable a site-wide CDN implementation. All local (served from this site) versions of Bootstrap will be superseded by any enabled "CDN Provider" below. <strong>Do not do both</strong>.') . '</div>');
$group
->setProperty('open', !!$default_provider);
// Intercept possible manual import of API data via AJAX callback.
$this
->importProviderData($form_state);
$providers = $this->theme
->getProviders();
$options = [];
foreach ($providers as $plugin_id => $provider) {
$options[$plugin_id] = $provider
->getLabel();
$this
->createProviderGroup($group, $provider);
}
// Override the options with the provider manager discovery.
$setting = $this
->getSettingElement($form, $form_state);
$setting
->setProperty('options', $options);
}