public function MenuExportForm::buildForm in Menu Import and Export 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/ MenuExportForm.php, line 35
Class
- MenuExportForm
- Configure Menu Export settings.
Namespace
Drupal\menu_export\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$menus = $this
->config('menu_export.settings')
->get('menus');
$menuEnt = Menu::loadMultiple($menus);
$menuData = array_map(function ($menuEnt) {
return $menuEnt
->label();
}, $menuEnt);
$form['menus_to_export'] = [
'#theme' => 'item_list',
'#title' => $this
->t('Menus to Export'),
'#items' => $menuData,
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Export Selected Menu Links'),
];
return $form;
}