public function SimpleCookieComplianceConfigForm::buildForm in Simple Cookie Compliance 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/ SimpleCookieComplianceConfigForm.php, line 32
Class
- SimpleCookieComplianceConfigForm
- Provides cookie compliance configuration form.
Namespace
Drupal\simple_cookie_compliance\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = \Drupal::config('simple_cookie_compliance.settings');
$form['expires'] = [
'#type' => 'textfield',
'#title' => $this
->t('Cookie expiration time'),
'#default_value' => $config
->get('expires'),
'#required' => TRUE,
'#description' => $this
->t('The time it will take to expire the cookie in seconds. Default value is equal to three months (7776000 seconds). Zero "0" means that the cookie never expires.'),
];
$form['no_script'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Display message'),
'#default_value' => $config
->get('no_script'),
'#description' => $this
->t('A clever description'),
];
$form['message'] = [
'#type' => 'text_format',
'#title' => $this
->t('Message'),
'#default_value' => $config
->get('message.value'),
'#required' => TRUE,
'#format' => !empty($config
->get('message.format')) ? $config
->get('message.format') : filter_fallback_format(),
];
$form['agree_button'] = [
'#type' => 'textfield',
'#title' => $this
->t('Agree button text'),
'#default_value' => $config
->get('agree_button'),
'#required' => TRUE,
];
return parent::buildForm($form, $form_state);
}