You are here

protected function WebformSubmissionForm::attachLibraries in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::attachLibraries()

Attach libraries to the form.

Parameters

array $form: An associative array containing the structure of the form.

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

1 call to WebformSubmissionForm::attachLibraries()
WebformSubmissionForm::form in src/WebformSubmissionForm.php
Gets the actual form array to be built.

File

src/WebformSubmissionForm.php, line 1174

Class

WebformSubmissionForm
Provides a webform to collect and edit submissions.

Namespace

Drupal\webform

Code

protected function attachLibraries(array &$form, FormStateInterface $form_state) {

  // Default: Add CSS and JS.
  // @see https://www.drupal.org/node/2274843#inline
  $form['#attached']['library'][] = 'webform/webform.form';

  // Assets: Add custom shared and webform specific CSS and JS.
  // @see webform_library_info_build()
  // @see _webform_page_attachments()
  $webform = $this
    ->getWebform();
  $assets = $webform
    ->getAssets();
  foreach ($assets as $type => $value) {
    if ($value) {
      $form['#attached']['library'][] = 'webform/webform.' . $type . '.' . $webform
        ->id();
    }
  }
}