function public function CdnProviderBase::alterForm

8.x-3.x CdnProviderBase.php public CdnProviderBase::alterForm(array &$form, FormStateInterface $form_state, $form_id = NULL)

The alter method to store the code.

Parameters

array $form: Nested array of form elements 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::alterForm

Class

CdnProviderBase
A base class for CDN Provider settings.

Namespace

Drupal\bootstrap\Plugin\Setting\Advanced\Cdn

Source src/Plugin/Setting/Advanced/Cdn/CdnProviderBase.php (line 41)

public function alterForm(array &$form, FormStateInterface $form_state, $form_id = NULL) {
  // Add autoload fix to make sure AJAX callbacks work.
  static::formAutoloadFix($form_state);

  // Attempt to extract the active provider from submitted values. Note: in
  // some cases, it needs to be extracted from the raw input if the values
  // haven't yet been populated.
  $input = $form_state->getUserInput();
  $provider = $form_state->getValue('cdn_provider', isset($input['cdn_provider']) ? Html::escape($input['cdn_provider']) : NULL);
  $this->provider = ProviderManager::load($this->theme, $provider);

  // Invoke the original alter.
  parent::alterForm($form, $form_state, $form_id);
}