You are here

public function JsInjectorForm::form in Asset Injector 8

Gets the actual form array to be built.

Overrides AssetInjectorFormBase::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

1 call to JsInjectorForm::form()
JsInjectorDuplicateForm::form in src/Form/JsInjectorDuplicateForm.php
Gets the actual form array to be built.
1 method overrides JsInjectorForm::form()
JsInjectorDuplicateForm::form in src/Form/JsInjectorDuplicateForm.php
Gets the actual form array to be built.

File

src/Form/JsInjectorForm.php, line 17

Class

JsInjectorForm
Class JsInjectorForm.

Namespace

Drupal\asset_injector\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\asset_injector\Entity\JsInjector $entity */
  $entity = $this->entity;
  $form['advanced']['jquery'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include jQuery'),
    '#description' => $this
      ->t('Not all pages load jQuery by default. Select this to include jQuery when loading this asset.'),
    '#options' => [
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes'),
    ],
    '#default_value' => $entity->jquery,
  ];
  $form['advanced']['preprocess'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Preprocess JS'),
    '#description' => $this
      ->t('If the JS is preprocessed, and JS aggregation is enabled, the script file will be aggregated.'),
    '#default_value' => $entity->preprocess,
  ];
  $form['advanced']['header'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Load the script in the header of the page'),
    '#default_value' => $entity->header,
  ];
  $form['code']['#attributes']['data-ace-mode'] = 'javascript';
  return $form;
}