public function ContentLinksForm::buildForm in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::buildForm()
- 3.0.x src/Form/ContentLinksForm.php \Drupal\gdpr\Form\ContentLinksForm::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/ ContentLinksForm.php, line 90
Class
- ContentLinksForm
- Class ContentLinksForm.
Namespace
Drupal\gdpr\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#tree'] = TRUE;
$form['description'] = [
'#markup' => $this
->t('Enter internal paths e.g <strong>@internal_path</strong> or full URLs e.g <strong>@full_url</strong>', [
'@internal_path' => '/privacy-policy',
'@full_url' => 'https://www.example.com/termsofservice.pdf',
]),
];
$form['links'] = [
'#type' => 'container',
];
$urls = $this
->loadUrls();
/** @var \Drupal\Core\Language\LanguageInterface $language */
foreach ($this->languageManager
->getLanguages() as $langCode => $language) {
$form['links'][$langCode] = [
'#type' => 'details',
'#title' => $language
->getName(),
];
foreach (static::requiredContentList() as $key => $label) {
$form['links'][$langCode][$key] = [
'#type' => 'textfield',
'#title' => $label,
'#process_default_value' => FALSE,
'#element_validate' => [
[
static::class,
'validateUriElement',
],
],
'#default_value' => isset($urls[$langCode][$key]) ? $urls[$langCode][$key] : NULL,
];
}
}
return parent::buildForm($form, $form_state);
}