1.20.x menu.module | menu_update_parent_options_ajax($form, $form_state) |
Ajax callback to replace the menu item parent options.
Whenever the item language changes, the available parents also have to get updated.
See also
File
- modules/
menu/ menu.module, line 404 - Allows administrators to customize the site's menus.
Code
function menu_update_parent_options_ajax($form, $form_state) {
if ($form['#form_id'] == 'menu_edit_item') {
$item = $form['original_item']['#value'];
if (isset($form_state['values']['langcode'])) {
$item['langcode'] = $form_state['values']['langcode'];
$form['parent']['#options'] = menu_parent_options(menu_get_menus(), $item);
}
return $form['parent'];
}
elseif (isset($form['#node'])) {
$item = $form['#node']->menu;
if (isset($form_state['values']['langcode'])) {
$item['langcode'] = $form_state['values']['langcode'];
$form['menu']['link']['parent']['#options'] = menu_parent_options(menu_get_menus(), $item, $form['#node']->type);
}
return $form['menu']['link']['parent'];
}
}