| Versions | |
|---|---|
| 4.7 | menu_edit_menu_form($mid = 0) |
| 5 | menu_edit_menu_form($type, $mid = 0) |
Menu callback; handle the adding/editing of a new menu.
modules/
<?php
function menu_edit_menu_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 {
$item = array(
'mid' => 0,
'pid' => 0,
'path' => '',
'weight' => 0,
'type' => MENU_CUSTOM_MENU,
);
}
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $item['title'],
'#description' => t('The name of the menu.'),
'#required' => TRUE,
);
$form['mid'] = array(
'#type' => 'value',
'#value' => $item['mid'],
);
$form['pid'] = array(
'#type' => 'value',
'#value' => $item['pid'],
);
$form['path'] = array(
'#type' => 'value',
'#value' => $item['path'],
);
$form['weight'] = array(
'#type' => 'value',
'#value' => $item['weight'],
);
$form['type'] = array(
'#type' => 'value',
'#value' => $item['type'],
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
// Reuse the submit function of menu_edit_item_form.
return drupal_get_form('menu_edit_menu_form', $form, 'menu_edit_item_form');
}
?>