1 menu.module menu_form_node_type_form_alter(&$form, $form_state)

Implements hook_form_FORM_ID_alter().

Adds menu options to the node type form.

File

core/modules/menu/menu.module, line 754
Allows administrators to customize the site's menus.

Code

function menu_form_node_type_form_alter(&$form, $form_state) {
  $menu_options = menu_get_menus();
  $node_type = $form['#node_type'];
  $form['menu'] = array(
    '#type' => 'fieldset',
    '#title' => t('Menu settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#attached' => array(
      'js' => array(backdrop_get_path('module', 'menu') . '/js/menu.admin.js'),
    ),
    '#group' => 'additional_settings',
    '#weight' => 15,
  );
  $form['menu']['menu_default'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add a link into the menu for new content of this type'),
    '#default_value' => $node_type->settings['menu_default'],
  );
  $form['menu']['menu_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Menus where this content may be placed'),
    '#default_value' => $node_type->settings['menu_options'],
    '#options' => $menu_options,
  );
  // To avoid an 'illegal option' error after saving the form we have to load
  // all available menu items.
  // Otherwise it is not possible to dynamically add options to the list.
  // @todo Convert menu_parent_options() into a #process callback.
  $options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
  $form['menu']['menu_parent'] = array(
    '#type' => 'select',
    '#title' => t('Default parent item'),
    '#default_value' => $node_type->settings['menu_parent'],
    '#options' => $options,
    '#description' => t('Links to content will be placed below this item in the menu.'),
    '#attributes' => array('class' => array('menu-title-select')),
  );

  // Call Backdrop.menu_update_parent_list() to filter the list of
  // available default parent menu items based on the selected menus.
  backdrop_add_js(
  '(function ($) { Backdrop.menu_update_parent_list(); })(jQuery);', 
  array('scope' => 'footer', 'type' => 'inline')
  );
}