menu_edit_item_form

Versions
4.6
menu_edit_item_form($edit)
4.7
menu_edit_item_form($mid = 0)
5
menu_edit_item_form($type, $mid = 0)

Present the menu item editing form.

▾ 2 functions call menu_edit_item_form()

menu_add_menu in modules/menu.module
Menu callback; handle the adding of a new menu.
menu_edit_item in modules/menu.module
Menu callback; dispatch to the appropriate menu item edit function.

Code

modules/menu.module, line 280

<?php
function menu_edit_item_form($edit) {
  $menu = menu_get_menu();

  $form .= form_textfield(t('Title'), 'title', $edit['title'], 60, 128, t('The name to display for this link.'), NULL, TRUE);

  if ($edit['pid'] == 0) {
    // Display a limited set of fields for menus (not items).
    $form .= form_hidden('path', '');
    $form .= form_hidden('pid', 0);
    $form .= form_hidden('weight', 0);
  }
  else {
    $form .= form_textfield(t('Description'), 'description', $edit['description'], 60, 128, t('The description displayed when hovering over a menu item.'));

    $path_description = t('The Drupal path this menu item links to.');
    if (isset($edit['path']) && array_key_exists($edit['path'], $menu['path index']) && $menu['path index'][$edit['path']] != $edit['mid']) {
      $old_mid = $menu['path index'][$edit['path']];
      $old_item = $menu['items'][$old_mid];
      $path_description .= "\n". t('Since a menu item "%old" already exists for "%path", this menu item is shortcut to that location.', array('%old' => l($old_item['title'], 'admin/menu/item/edit/'. $old_mid), '%path' => $edit['path']));
    }

    if ($edit['type'] & MENU_CREATED_BY_ADMIN) {
      $form .= form_textfield(t('Path'), 'path', $edit['path'], 60, 128, $path_description, NULL, TRUE);
    }
    else {
      $form .= form_item(t('Path'), l($edit['path'], $edit['path']));
      $form .= form_hidden('path', $edit['path']);
    }

    $form .= form_checkbox(t('Expanded'), 'expanded', 1, ($edit['type'] & MENU_EXPANDED), t('If selected and this menu item has children, the menu will always appear expanded.'));

    // Generate a list of possible parents (not including this item or descendants).
    $options = menu_parent_options($edit['mid']);
    $form .= form_select(t('Parent item'), 'pid', $edit['pid'], $options);

    $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'));
  }

  $form .= form_submit(t('Submit'));

  $form .= form_hidden('mid', $edit['mid']);

  // Always enable menu items (but not menus) when editing them.
  if (!($edit['type'] & MENU_IS_ROOT)) {
    $edit['type'] |= MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB;
  }

  $form .= form_hidden('type', $edit['type']);

  return form($form);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.