function nodehierarchy_parent_selector_validate in Node Hierarchy 7.4
Same name and namespace in other branches
- 6.3 nodehierarchy.module \nodehierarchy_parent_selector_validate()
- 6.2 nodehierarchy.module \nodehierarchy_parent_selector_validate()
- 7.2 nodehierarchy.module \nodehierarchy_parent_selector_validate()
Validate the parent node selector to make sure the parent is legal.
1 string reference to 'nodehierarchy_parent_selector_validate'
- _nodehierarchy_get_parent_selector in ./
nodehierarchy.admin.inc - Get the parent selector pulldown.
File
- ./
nodehierarchy.admin.inc, line 471 - Admin functions for Node Hierarchy
Code
function nodehierarchy_parent_selector_validate($element, &$form_state) {
$selection = @$element['#items'][$element['#value']];
if (is_array($selection) && !empty($selection['disabled'])) {
form_error($element, t('You have selected a parent node which cannot be a parent of this node type.'));
if (!empty($selection['nid']) && !empty($form_state['values']['nid']) && in_array($form_state['values']['nid'], nodehierarchy_get_node_ancestor_nids($selection['nid']))) {
form_error($element, t('The parent of this node can not be itself or any if its decendants.'));
}
}
}