You are here

function tft_form_alter in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 8 tft.module \tft_form_alter()
  2. 7 tft.module \tft_form_alter()
  3. 3.x tft.module \tft_form_alter()

Implements hook_form_alter()

Related topics

File

./tft.module, line 200
Hook implementations and module logic for TFT.

Code

function tft_form_alter(&$form, &$form_state, $form_id) {
  $setting = tft_get_file_setting();
  switch ($form_id) {
    case $setting['type'] . '_node_form':
      $path = drupal_get_path('module', 'tft');
      drupal_add_js("{$path}/js/tft.select-folder.js");
      drupal_add_css("{$path}/css/tft.css");
      module_load_include('inc', 'tft', 'tft.pages');
      $form['tft_folder'][LANGUAGE_NONE]['#prefix'] = '<div class="tft-hide-element element-hidden">' . (!empty($form['tft_folder'][LANGUAGE_NONE]['#prefix']) ? $form['tft_folder'][LANGUAGE_NONE]['#prefix'] : '');
      $form['tft_folder'][LANGUAGE_NONE]['#suffix'] = (!empty($form['tft_folder'][LANGUAGE_NONE]['#suffix']) ? $form['tft_folder'][LANGUAGE_NONE]['#suffix'] : '') . '</div>';
      $form['tft_select_folder'] = array(
        '#type' => 'fieldset',
        '#title' => t("Select folder"),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#weight' => $form['tft_folder']['#weight'],
      );
      if (isset($_GET['tid'])) {
        $tid = $_GET['tid'];
      }
      elseif (isset($form['#node']->tft_folder[LANGUAGE_NONE][0]['tid'])) {
        $tid = $form['#node']->tft_folder[LANGUAGE_NONE][0]['tid'];
      }
      $tid = !empty($tid) ? $tid : 0;
      $form['tft_select_folder']['tft_js_folder'] = array(
        '#markup' => '<div id="folder-explorer-container" class="tft-node-form">' . tft_output_tree(tft_folder_tree(0, TRUE)) . '</div>',
      );
      $form['tft_selected_folder'] = array(
        '#type' => 'hidden',
        '#default_value' => $tid,
      );
      break;
  }
}