You are here

public function SettingsForm::buildForm in Minify Source HTML 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/SettingsForm.php, line 25

Class

SettingsForm
Settings form for the module.

Namespace

Drupal\minifyhtml\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $config = $this
    ->config('minifyhtml.config');
  $form['minifyhtml_minify'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Minified Source HTML.'),
    '#description' => $this
      ->t('Toggle minified HTML on or off.'),
    '#default_value' => $config
      ->get('minify'),
  ];
  $form['strip_comments'] = [
    '#title' => $this
      ->t('Strip comments from the source HTML'),
    '#description' => $this
      ->t('If checked, strip HTML comments and multi-line comments in @script and @style tags.', [
      '@script' => '<script>',
      '@style' => '<style>',
    ]),
    '#type' => 'checkbox',
    '#default_value' => $config
      ->get('strip_comments'),
  ];
  return $form;
}