You are here

public function cookieBannerConfigForm::buildForm in Cookie_Banner 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/cookieBannerConfigForm.php, line 44
Contains Drupal\cookie_banner\Form\cookieBannerConfigForm.

Class

cookieBannerConfigForm
Class cookieBannerConfigForm.

Namespace

Drupal\cookie_banner\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('cookie_banner.settings');
  $form['cookie_banner']['use_cookie_message'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Cookie policy main message'),
    '#default_value' => $config
      ->get('use_cookie_message'),
    '#size' => 62,
    '#maxlength' => 220,
    '#required' => TRUE,
    '#description' => $this
      ->t('Enter the message to warn the user about the site using cookies.'),
  );
  $form['cookie_banner']['more_info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Cookie Policy link'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['cookie_banner']['more_info']['more_info_url'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Link URL'),
    '#default_value' => $config
      ->get('more_info_url'),
    '#size' => 60,
    '#maxlength' => 220,
    '#required' => TRUE,
    '#description' => $this
      ->t('Enter link to your privacy policy or other page that will explain cookies to your users. For external links prepend http://'),
  );
  $form['cookie_banner']['more_info']['more_info_message'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Link text'),
    '#default_value' => $config
      ->get('more_info_message'),
    '#size' => 60,
    '#maxlength' => 220,
    '#required' => TRUE,
    '#description' => $this
      ->t('Enter the text for the Privacy Policy link.'),
  );
  return parent::buildForm($form, $form_state);
}