You are here

public function OutdatedbrowserSettingsForm::buildForm in Outdated Browser 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/OutdatedbrowserSettingsForm.php, line 37
Administrative class form for the outdatedbrowser module.

Class

OutdatedbrowserSettingsForm
General configuration form for controlling the outdatedbrowser behaviour..

Namespace

Drupal\outdatedbrowser\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Load all settings.
  $config = $this
    ->config('outdatedbrowser.settings');
  $form['outdatedbrowser_compression_type'] = array(
    '#title' => t('Outdated Browser library compression type'),
    '#type' => 'select',
    '#options' => array(
      'minified' => t('Minified (production)'),
      'source' => t('Uncompressed (development version)'),
    ),
    '#default_value' => $config
      ->get('compression_type'),
    '#required' => TRUE,
  );
  $form['outdatedbrowser_bgcolor'] = array(
    '#title' => t('Outdated Browser message: background color'),
    '#description' => t('The background color of the displayed browser upgrade advice. Must be a valid hexadecimal CSS color string, such as @hex.', array(
      '@hex' => '#f25648',
    )),
    '#type' => 'color',
    '#default_value' => $config
      ->get('bgcolor'),
    '#required' => TRUE,
  );
  $form['outdatedbrowser_color'] = array(
    '#title' => t('Outdated Browser message: font color'),
    '#description' => t('The font color of the displayed browser upgrade advice. Must be a valid hexadecimal CSS color string, such as @hex.', array(
      '@hex' => '#ffffff',
    )),
    '#type' => 'color',
    '#default_value' => $config
      ->get('color'),
    '#required' => TRUE,
  );
  $form['outdatedbrowser_lowerthan'] = array(
    '#title' => t('Outdated Browser message: targeting browser'),
    '#description' => t('The targeting browser of the displayed browser upgrade advice, either a CSS property or an Internet Explorer version.'),
    '#type' => 'textfield',
    '#default_value' => $config
      ->get('lowerthan'),
    '#required' => TRUE,
  );
  $form['outdatedbrowser_lang_files_path'] = array(
    '#title' => t('Outdated Browser message files'),
    '#description' => t('Language files location - you can use the outdatedbrowser library path or your own path with additional language files added and HTML/css adapted.'),
    '#type' => 'textfield',
    '#default_value' => $config
      ->get('lang_files_path', 'libraries/outdated-browser/outdatedbrowser/lang'),
    '#required' => TRUE,
  );
  return parent::buildForm($form, $form_state);
}