You are here

public function LinkedinInsightsAdminSettingsForm::buildForm in LinkedIn Insights Tag 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/LinkedinInsightsAdminSettingsForm.php, line 30

Class

LinkedinInsightsAdminSettingsForm
Configure Google_Analytics settings for this site.

Namespace

Drupal\linkedin_insights_tag\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('linkedin_insights_tag.settings');
  $visibility_user_role_roles = $config
    ->get('user_role_roles');
  $form['linkedin_insights_tag_partner_id'] = [
    '#default_value' => $config
      ->get('partner_id'),
    '#description' => $this
      ->t('Partner ID provided by Linkedin Insights.'),
    '#maxlength' => 50,
    '#required' => TRUE,
    '#size' => 20,
    '#title' => $this
      ->t('Partner ID'),
    '#type' => 'textfield',
  ];
  $form['linkedin_insights_tag_visibility_user_role_roles'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Load Linkedin Insights for following user roles:'),
    '#default_value' => !empty($visibility_user_role_roles) ? $visibility_user_role_roles : [],
    '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', user_role_names()),
    '#description' => $this
      ->t('If none of the roles are selected, all
       users will be tracked.If a user has any of the roles checked, that user
       will be tracked (or excluded, depending on the setting above).'),
  ];
  $form['linkedin_insights_image_only'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Force image usage only'),
    '#description' => $this
      ->t('Choose this option whenever you want to force
        the tracking to only use the image pixel and not javascript.'),
    '#default_value' => $config
      ->get('image_only'),
  ];
  return parent::buildForm($form, $form_state);
}