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.


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


A base class for CDN Provider settings.



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.

  // 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);