You are here

public function OlarkSettings::buildForm in Olark Chat 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/OlarkSettings.php, line 51

Class

OlarkSettings
Configures Olark settings for this site.

Namespace

Drupal\olark\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $settings = \Drupal::config('olark.settings');
  $form['olark_enable'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Olark'),
    '#default_value' => $settings
      ->get('olark_enable', TRUE),
    '#description' => $this
      ->t('Enable / disable Olark integration for this site.'),
  ];
  $form['olark_code'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Olark code'),
    '#description' => $this
      ->t('Paste the Javascript code block from <a href="http://olark.com/install">Olark.com</a>'),
    '#default_value' => $settings
      ->get('olark_code'),
    '#attributes' => [
      'placeholder' => '<!-- begin olark code -->',
    ],
  ];
  $form['olark_ios'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable in iOS devices'),
    '#description' => $this
      ->t('Hides it on iPhone, iPad and iPod since it has issues in this platforms.'),
    '#default_value' => $settings
      ->get('olark_ios'),
  ];
  $form['olark_enable_admin'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable on admin pages.'),
    '#description' => $this
      ->t('Embeds the olark code on admin pages.'),
    '#default_value' => $settings
      ->get('olark_enable_admin'),
  ];
  return parent::buildForm($form, $form_state);
}