You are here

public function PwaExtrasSettingsForm::buildForm in Progressive Web App 2.x

Same name and namespace in other branches
  1. 8 modules/pwa_extras/src/Form/PwaExtrasSettingsForm.php \Drupal\pwa_extras\Form\PwaExtrasSettingsForm::buildForm()

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

modules/pwa_extras/src/Form/PwaExtrasSettingsForm.php, line 23

Class

PwaExtrasSettingsForm
PWA Extras admin settings form.

Namespace

Drupal\pwa_extras\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('pwa_extras.settings.apple');
  $form['apple'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Apple/IOS Specific Settings'),
    '#open' => TRUE,
  ];
  $form['apple']['touch_icons'] = [
    "#type" => 'checkboxes',
    "#title" => $this
      ->t('Touch Icons'),
    "#options" => str_replace('<', '&lt;', pwa_extras_apple_touch_icons()),
    '#default_value' => $config
      ->get('touch_icons'),
  ];
  $form['apple']['meta_tags'] = [
    "#type" => 'checkboxes',
    "#title" => $this
      ->t('Meta Tags'),
    "#options" => str_replace('<', '&lt;', pwa_extras_apple_meta_tags()),
    '#default_value' => $config
      ->get('meta_tags'),
  ];
  $form['apple']['color_select'] = [
    "#type" => 'select',
    "#title" => $this
      ->t('Select color for status-bar-style'),
    '#options' => [
      'default' => $this
        ->t('Default'),
      'black' => $this
        ->t('Black'),
      'black_translucent' => $this
        ->t('Black-translucent'),
    ],
    '#states' => [
      'invisible' => [
        ':input[value="meta-status-bar-style"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#default_value' => $config
      ->get('color_select'),
  ];
  $form['apple']['home_screen_icons'] = [
    "#type" => 'checkboxes',
    "#title" => $this
      ->t('Add to homescreen icons'),
    "#options" => str_replace('<', '&lt;', pwa_extras_apple_home_screen_icons()),
    '#default_value' => $config
      ->get('home_screen_icons'),
  ];
  return parent::buildForm($form, $form_state);
}