function nodehierarchy_children_form in Node Hierarchy 7.4
Same name and namespace in other branches
- 6.3 nodehierarchy.module \nodehierarchy_children_form()
- 6.2 nodehierarchy.module \nodehierarchy_children_form()
- 7.2 nodehierarchy.module \nodehierarchy_children_form()
Built the children tab form.
1 string reference to 'nodehierarchy_children_form'
- nodehierarchy_view_children in ./
nodehierarchy.admin.inc - Display the children tab.
File
- ./
nodehierarchy.admin.inc, line 312 - Admin functions for Node Hierarchy
Code
function nodehierarchy_children_form($form, &$form_state, $node) {
$form = array();
// $children_links = _nodehierarchy_get_children_menu_links($node->nid, FALSE);
$children = nodehierarchy_get_node_children($node, FALSE);
$form['children'] = array(
'#tree' => TRUE,
);
$type_names = node_type_get_names();
// Find the maximum weight.
$delta = count($children);
foreach ($children as $child) {
$delta = max($delta, $child->cweight);
}
foreach ($children as $child) {
if ($node = node_load($child->cnid)) {
$child_item = array();
$child_item['child'] = array(
'#type' => 'value',
'#value' => $child,
);
$child_item['node'] = array(
'#type' => 'value',
'#value' => $node,
);
$child_item['title'] = array(
'#type' => 'markup',
'#markup' => l($node->title, 'node/' . $node->nid),
);
$child_item['type'] = array(
'#type' => 'markup',
'#markup' => $type_names[$node->type],
);
$child_item['cweight'] = array(
'#type' => 'weight',
'#delta' => $delta,
'#default_value' => isset($form_state[$child->nhid]['cweight']) ? $form_state[$child->nhid]['cweight'] : $child->cweight,
);
$form['children'][$child->nhid] = $child_item;
}
}
if (element_children($form['children'])) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save child order'),
);
}
else {
$form['no_children'] = array(
'#type' => 'markup',
'#markup' => t('This node has no children.'),
);
}
return $form;
}