You are here

function sitemap_alter_menu_forms in Sitemap 8

Handles the form alter for the menu_add_form and menu_edit_form forms to add a settings field to the menu entity.

1 call to sitemap_alter_menu_forms()
sitemap_form_alter in ./sitemap.module
Implements hook_form_alter().

File

./sitemap.module, line 246
Provides sitemap functionality.

Code

function sitemap_alter_menu_forms(&$form, FormStateInterface $form_state, $form_id) {
  $menu = $form_state
    ->getFormObject()
    ->getEntity();
  $form['sitemap_display_name'] = [
    '#type' => 'textfield',
    '#title' => t('Sitemap display name'),
    '#description' => t('A user-friendly name for the menu that will display on the sitemap.'),
    '#default_value' => $menu
      ->getThirdPartySetting('sitemap', 'sitemap_display_name'),
    '#weight' => 1,
  ];
  if (isset($form['links'])) {
    $form['links']['#weight'] = 2;
  }
  $form['#entity_builders'][] = 'sitemap_form_menu_add_form_builder';
}