function _menu_link_weight_get_parent_value_from_element in Menu Link Weight 7
Same name and namespace in other branches
- 8.2 menu_link_weight.module \_menu_link_weight_get_parent_value_from_element()
- 8 menu_link_weight.module \_menu_link_weight_get_parent_value_from_element()
Gets the menu link parent value from the form.
Helper function for menu link weight process callback.
Parameters
array $parent_element: Menu link parent form element.
array $form_state: Form state array.
Return value
string Menu link
2 calls to _menu_link_weight_get_parent_value_from_element()
- menu_link_weight_node_element_process in ./
menu_link_weight.module - Process callback for the menu link weight element.
- menu_link_weight_node_form_validate in ./
menu_link_weight.module - Validation hook for the menu_link weight element.
File
- ./
menu_link_weight.module, line 225 - Replaces the menu link weight dropdown with a tabledrag widget.
Code
function _menu_link_weight_get_parent_value_from_element(array $parent_element, array $form_state) {
$value = FALSE;
if ($parent_element['#type'] == 'hierarchical_select' && function_exists('_hs_process_determine_hsid') && function_exists('_hierarchical_select_process_calculate_selections')) {
// Added for compatibility with the Hierarchical Select module.
$hsid = _hs_process_determine_hsid($parent_element, $form_state);
list($hs_selection, $db_selection) = _hierarchical_select_process_calculate_selections($parent_element, $hsid, $form_state);
$value = $hs_selection;
}
else {
if (isset($form_state['values']['menu']['parent'])) {
$value = $form_state['values']['menu']['parent'];
}
else {
$value = !empty($parent_element['#value']) ? $parent_element['#value'] : $parent_element['#default_value'];
}
}
// The menu_link_sync and hierarchical_select modules transform the parent
// value into an array.
if (is_array($value) && isset($value[0])) {
$value = $value[0];
}
return $value;
}