function menu_edit_menu_submit

Submit function for adding or editing a custom menu.

File

modules/menu/menu.admin.inc, line 600

Code

function menu_edit_menu_submit($form, &$form_state) {
    $menu = $form_state['values'];
    $path = 'admin/structure/menu/manage/';
    if ($form['#insert']) {
        // Add 'menu-' to the menu name to help avoid name-space conflicts.
        $menu['menu_name'] = 'menu-' . $menu['menu_name'];
        $link['link_title'] = $menu['title'];
        $link['link_path'] = $path . $menu['menu_name'];
        $link['router_path'] = $path . '%';
        $link['module'] = 'menu';
        $link['plid'] = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :link AND module = :module", array(
            ':link' => 'admin/structure/menu',
            ':module' => 'system',
        ))->fetchField();
        menu_link_save($link);
        menu_save($menu);
    }
    else {
        menu_save($menu);
        $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path", array(
            ':path' => $path . $menu['menu_name'],
        ), array(
            'fetch' => PDO::FETCH_ASSOC,
        ));
        foreach ($result as $m) {
            $link = menu_link_load($m['mlid']);
            $link['link_title'] = $menu['title'];
            menu_link_save($link);
        }
    }
    drupal_set_message(t('Your configuration has been saved.'));
    $form_state['redirect'] = $path . $menu['menu_name'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.