public function XmlSitemapForm::form in XML sitemap 2.x
Same name and namespace in other branches
- 8 src/Form/XmlSitemapForm.php \Drupal\xmlsitemap\Form\XmlSitemapForm::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/ XmlSitemapForm.php, line 25
Class
- XmlSitemapForm
- Provides a form for creating and editing xmlsitemap entities.
Namespace
Drupal\xmlsitemap\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
if ($this->entity
->getContext() == NULL) {
$this->entity->context = [];
}
$xmlsitemap = $this->entity;
$form['#entity'] = $xmlsitemap;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $xmlsitemap
->label(),
'#description' => $this
->t('Label for the XML sitemap.'),
'#required' => TRUE,
];
$form['context'] = [
'#tree' => TRUE,
];
if (!xmlsitemap_get_context_info()) {
$form['context']['empty'] = [
'#type' => 'markup',
'#markup' => '<p>' . $this
->t('There are currently no XML sitemap contexts available.') . '</p>',
];
}
return $form;
}