You are here

public function AdminConfigure::buildForm in Image Lazyloader 8

Form constructor.

Parameters

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

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

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/AdminConfigure.php, line 84

Class

AdminConfigure
Class AdminConfigure.

Namespace

Drupal\lazyloader\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = [];
  $config = $this
    ->config('lazyloader.configuration');
  $form['enabled'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enabled'),
    '#default_value' => $config
      ->get('enabled'),
    '#description' => $this
      ->t('Enable/Disable Lazyloader (Useful for testing)'),
  ];
  $form['debugging'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use development javascript'),
    '#default_value' => $config
      ->get('debugging'),
    '#description' => $this
      ->t('By default lazyloader will use the minified version of the lazysizes library. By checking this option it will use the non-minified version instead.'),
  ];
  $form['cdn'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Serve javascript from CDN'),
    '#default_value' => $config
      ->get('cdn'),
    '#description' => $this
      ->t('Serve the lazyloading script from a CDN instead of your own server'),
  ];
  $form['placeholder'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Placeholder Image'),
    '#default_value' => $config
      ->get('placeholder'),
    '#description' => $this
      ->t('Path to your placeholder image, ex. sites/default/files/placeholder_image.gif. Leave it blank to use the default image.'),
  ];
  return parent::buildForm($form, $form_state);
}