function menu_edit_item_form in Drupal 4
Same name and namespace in other branches
- 5 modules/menu/menu.module \menu_edit_item_form()
Present the menu item editing form.
2 string references to 'menu_edit_item_form'
- menu_edit_menu_form in modules/
menu.module - Menu callback; handle the adding/editing of a new menu.
- menu_menu in modules/
menu.module - Implementation of hook_menu().
File
- modules/
menu.module, line 334 - Allows administrators to customize the site navigation menu.
Code
function menu_edit_item_form($mid = 0) {
if (arg(3) == 'edit') {
if (!($item = db_fetch_array(db_query('SELECT * FROM {menu} WHERE mid = %d', $mid)))) {
drupal_not_found();
return;
}
}
else {
// This is an add form.
// The mid argument (if set) will be the default pid to use.
// Otherwise, we default to the "Navigation" menu (pid #1).
$default_pid = $mid ? $mid : 1;
$item = array(
'mid' => 0,
'pid' => $default_pid,
'weight' => 0,
'type' => MENU_CUSTOM_ITEM,
);
}
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $item['title'],
'#description' => t('The name of the menu item.'),
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $item['description'],
'#description' => t('The description displayed when hovering over a menu item.'),
);
if ($item['type'] & MENU_CREATED_BY_ADMIN) {
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => $item['path'],
'#description' => t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array(
'%front' => theme('placeholder', '<front>'),
'%add-node' => theme('placeholder', 'node/add'),
'%drupal' => theme('placeholder', 'http://drupal.org'),
)),
'#required' => TRUE,
);
}
else {
$form['_path'] = array(
'#type' => 'item',
'#title' => t('Path'),
'#description' => l($item['path'], $item['path']),
);
$form['path'] = array(
'#type' => 'value',
'#value' => $item['path'],
);
}
$expanded = $item['type'] & MENU_EXPANDED ? 1 : 0;
$form['expanded'] = array(
'#type' => 'checkbox',
'#title' => t('Expanded'),
'#default_value' => $expanded,
'#description' => 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($item['mid']);
$form['pid'] = array(
'#type' => 'select',
'#title' => t('Parent item'),
'#default_value' => $item['pid'],
'#options' => $options,
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $item['weight'],
'#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
// Always enable menu items (but not menus) when editing them.
if (!($item['type'] & MENU_IS_ROOT)) {
$item['type'] |= MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB;
}
$form['type'] = array(
'#type' => 'value',
'#value' => $item['type'],
);
$form['mid'] = array(
'#type' => 'value',
'#value' => $item['mid'],
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return drupal_get_form('menu_edit_item_form', $form);
}