Trying to add an extra field to menu items (an icon field). I added the icon field to menu table and if I manually update menu item in database, the menu item returns with the icon field. However, it doesn't save the icon field from the form.
function menu_form_alter($form_id, &$form) {
// ...
$form['menu']['path'] = array('#type' => 'hidden',
'#value' => $item['path'],
);
// ...
}
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, 'icon' => '');
}
$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['icon'] = array('#type' => 'value', '#value' => $item['icon']);
$form['type'] = array('#type' => 'value', '#value' => $item['type']);