public function CookieCategoryForm::form in EU Cookie Compliance (GDPR Compliance) 8
Same name and namespace in other branches
- 2.0.x src/Form/CookieCategoryForm.php \Drupal\eu_cookie_compliance\Form\CookieCategoryForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ CookieCategoryForm.php, line 47
Class
- CookieCategoryForm
- Class CookieCategoryForm.
Namespace
Drupal\eu_cookie_compliance\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$cookie_category = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $cookie_category
->label(),
'#description' => $this
->t("The name that will be shown to the website visitor."),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $cookie_category
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\eu_cookie_compliance\\Entity\\CookieCategory::load',
],
'#changeable_state' => !$cookie_category
->isNew(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Description'),
'#default_value' => $cookie_category
->get('description'),
'#description' => $this
->t("The description that will be shown to the website visitor."),
'#required' => FALSE,
];
$form['checkbox_default_state'] = [
'#type' => 'radios',
'#title' => $this
->t('Checkbox default state'),
'#description' => $this
->t("Determines the default state of this category's selection checkbox on the cookie consent popup."),
'#default_value' => $cookie_category
->get('checkbox_default_state') ?: 'unchecked',
'#options' => $this->categoryStorageManager
->getCheckboxDefaultStateOptionsList(),
'#required' => TRUE,
];
return $form;
}