You are here

function tft_og_form_alter in Taxonomy File Tree 7.2

Implements hook_form_alter()

File

modules/tft_og/tft_og.module, line 184
Hook implementations for TFT OG.

Code

function tft_og_form_alter(&$form, &$form_state, $form_id) {
  $setting = tft_get_file_setting();
  switch ($form_id) {
    case $setting['type'] . '_node_form':
      $form['og_group_ref'][LANGUAGE_NONE]['#prefix'] = '<div class="tft-hide-element element-hidden">' . (!empty($form['og_group_ref'][LANGUAGE_NONE]['#prefix']) ? $form['og_group_ref'][LANGUAGE_NONE]['#prefix'] : '');
      $form['og_group_ref'][LANGUAGE_NONE]['#suffix'] .= '</div>';
      $og_nid = $form['og_group_ref'][LANGUAGE_NONE][0]['default']['#default_value'];
      if (empty($og_nid) && !empty($form['og_group_ref'][LANGUAGE_NONE][0]['admin'][0]['target_id']['#entity']->og_group_ref[LANGUAGE_NONE][0]['target_id'])) {
        $og_nid = array(
          $form['og_group_ref'][LANGUAGE_NONE][0]['admin'][0]['target_id']['#entity']->og_group_ref[LANGUAGE_NONE][0]['target_id'],
        );
      }
      if (!empty($og_nid)) {

        // Overwrite the folder select field.
        $og_tid = tft_og_get_og_tid($og_nid[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($og_tid, TRUE)) . '</div>',
        );
        $form['#validate'][] = 'tft_og_file_node_validate';
      }
      break;
  }
}