public function PageGeneralForm::buildForm in Page Manager 8
Same name and namespace in other branches
- 8.4 page_manager_ui/src/Form/PageGeneralForm.php \Drupal\page_manager_ui\Form\PageGeneralForm::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 FormInterface::buildForm
File
- page_manager_ui/
src/ Form/ PageGeneralForm.php, line 66 - Contains \Drupal\page_manager_ui\Form\PageGeneralForm.
Class
Namespace
Drupal\page_manager_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/** @var $page \Drupal\page_manager\Entity\Page */
$page = $cached_values['page'];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this
->t('Administrative description'),
'#default_value' => $page
->getDescription(),
];
$form['path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Path'),
'#maxlength' => 255,
'#default_value' => $page
->getPath(),
'#required' => TRUE,
'#element_validate' => [
[
$this,
'validatePath',
],
],
];
$form['use_admin_theme'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use admin theme'),
'#default_value' => $page
->usesAdminTheme(),
];
if ($page
->isNew()) {
$variant_plugin_options = [];
foreach ($this->variantManager
->getDefinitions() as $plugin_id => $definition) {
// The following two variants are provided by Drupal Core. They are not
// configurable and therefore not compatible with Page Manager but have
// similar and confusing labels. Skip them so that they are not shown in
// the UI.
if (in_array($plugin_id, [
'simple_page',
'block_page',
])) {
continue;
}
$variant_plugin_options[$plugin_id] = $definition['admin_label'];
}
$form['variant_plugin_id'] = [
'#title' => $this
->t('Variant type'),
'#type' => 'select',
'#options' => $variant_plugin_options,
'#default_value' => !empty($cached_values['variant_plugin_id']) ? $cached_values['variant_plugin_id'] : '',
];
$form['wizard_options'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Optional features'),
'#description' => $this
->t('Check any optional features you need to be presented with forms for configuring them. If you do not check them here you will still be able to utilize these features once the new page is created. If you are not sure, leave these unchecked.'),
'#options' => [
'access' => $this
->t('Page access'),
'contexts' => $this
->t('Variant contexts'),
'selection' => $this
->t('Variant selection criteria'),
],
'#default_value' => !empty($cached_values['wizard_options']) ? $cached_values['wizard_options'] : [],
];
}
return $form;
}