You are here

function nodehierarchy_parent_selector_validate in Node Hierarchy 6.2

Same name and namespace in other branches
  1. 6.3 nodehierarchy.module \nodehierarchy_parent_selector_validate()
  2. 7.4 nodehierarchy.admin.inc \nodehierarchy_parent_selector_validate()
  3. 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.module
Get the parent selector pulldown.

File

./nodehierarchy.module, line 1499
A module to make nodes hierarchical.

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 (is_array($selection) && 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.'));
  }
}