You are here

function taxonomy_manager_tree_build_child_form in Taxonomy Manager 7

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \taxonomy_manager_tree_build_child_form()
  2. 6.2 taxonomy_manager.module \taxonomy_manager_tree_build_child_form()
  3. 6 taxonomy_manager.module \taxonomy_manager_tree_build_child_form()

callback for generating and rendering nested child forms (AHAH)

Parameters

$tree_id:

$parent term id of parent, that is expanded and of which children have to be loaded:

1 string reference to 'taxonomy_manager_tree_build_child_form'
taxonomy_manager_menu in ./taxonomy_manager.module
Implements hook_menu().

File

./taxonomy_manager.module, line 793
Taxonomy Manager

Code

function taxonomy_manager_tree_build_child_form($tree_id, $vid, $parent) {
  $params = $_GET;
  $form_state = form_state_defaults();
  $form_state['method'] = 'get';
  $form_state['values'] = array();
  $form_state['process_input'] = TRUE;
  $form_state['input'] = array();
  $form_state['complete form'] = array();
  $tids = array();
  if (isset($params['#terms_to_expand']) && $params['#terms_to_expand'] != 0) {

    // convert to array
    $tids = explode(',', $params['#terms_to_expand']);
  }
  if (count($tids) == 1) {
    $language = _taxonomy_manager_term_get_lang($tids[0]);
  }
  else {
    $language = $params['language'];
  }
  $child_form = array(
    '#type' => 'taxonomy_manager_tree',
    '#vid' => $vid,
    '#parent' => $parent,
    '#pager' => TRUE,
    '#language' => $language,
    '#terms_to_expand' => $tids,
    '#siblings_page' => 1,
  );
  $opertions_callback = 'taxonomy_manager_' . str_replace('-', '_', $tree_id) . '_operations';
  if (function_exists($opertions_callback)) {
    $child_form['#operations_callback'] = $opertions_callback;
  }
  $link_callback = 'taxonomy_manager_' . str_replace('-', '_', $tree_id) . '_link';
  if (function_exists($link_callback)) {
    $child_form['#link_callback'] = $link_callback;
  }
  _taxonomy_manager_tree_sub_forms_set_parents($params['form_parents'], $parent, $child_form);
  $child_form = form_builder('taxonomy_manager_form', $child_form, $form_state);
  print drupal_json_output(array(
    'data' => drupal_render($child_form),
  ));
  ajax_footer();
}