function public static function FormAutoloadFixTrait::formAutoloadFix

8.x-3.x FormAutoloadFixTrait.php public static FormAutoloadFixTrait::formAutoloadFix(FormStateInterface $form_state)

Adds the autoload fix include file to the form state.

This may be necessary if you notice your AJAX callbacks not working.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

Class

FormAutoloadFixTrait
Trait FormAutoloadFixTrait.

Namespace

Drupal\bootstrap\Traits

Source src/Traits/FormAutoloadFixTrait.php (line 21)

public static function formAutoloadFix(FormStateInterface $form_state) {
  $files = $form_state->getBuildInfo()['files'];

  // Only add the include once.
  $file = Bootstrap::autoloadFixInclude();
  $key = array_search($file, $files);
  if ($key === FALSE) {
    array_unshift($files, $file);
    $form_state->addBuildInfo('files', $files);
  }
}