You are here

public function LiveChatSettingsForm::buildForm in LiveChat 8

Same name and namespace in other branches
  1. 8.2 src/Form/LiveChatSettingsForm.php \Drupal\livechat\Form\LiveChatSettingsForm::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

src/Form/LiveChatSettingsForm.php, line 32

Class

LiveChatSettingsForm
Configure Coffee for this site.

Namespace

Drupal\livechat\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config(LIVECHAT_CONFIGURATION_NAME);
  $form['path'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Visibility'),
    '#open' => TRUE,
  ];
  $form['path']['livechat_visibility'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Show LiveChat on'),
    '#options' => array(
      LIVECHAT_VISIBILITY_NOTLISTED => $this
        ->t('All pages except those listed'),
      LIVECHAT_VISIBILITY_LISTED => $this
        ->t('Only the listed pages'),
    ),
    '#default_value' => $config
      ->get('livechat_visibility'),
  ];
  $form['path']['livechat_pages'] = [
    '#type' => 'textarea',
    '#default_value' => $config
      ->get('livechat_pages'),
    '#description' => $this
      ->t("Specify pages by using their paths. Enter one path per\n      line. The '*' character is a wildcard. Example paths are %blog for the blog\n      page and %blog-wildcard for every personal blog. %front is the\n      front page.", [
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    ]),
  ];
  $form['path']['livechat_exclude_system_paths'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable LiveChat on common system paths (recommended)'),
    '#description' => $this
      ->t('LiveChat will not trigger on the following paths: %paths', [
      '%paths' => str_replace("\n", ', ', LIVECHAT_VISIBILITY_SYSTEM_PATHS),
    ]),
    '#default_value' => $config
      ->get('livechat_exclude_system_paths'),
  ];
  $form['livechat_group'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Group Id'),
    '#description' => $this
      ->t('If you are using LiveChat on more than one website,
       enter the id of the website here'),
    '#default_value' => $config
      ->get('livechat_group'),
  ];
  $form['livechat_enabled'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable LiveChat'),
    '#description' => $this
      ->t('Uncheck this box to disable LiveChat.'),
    '#default_value' => $config
      ->get('livechat_enabled'),
  ];
  return parent::buildForm($form, $form_state);
}