You are here

function theme_taxonomy_defaults_form in Taxonomy Defaults 7

Same name and namespace in other branches
  1. 5 taxonomy_defaults.module \theme_taxonomy_defaults_form()
  2. 6.2 taxonomy_defaults.admin.inc \theme_taxonomy_defaults_form()
  3. 6 taxonomy_defaults.admin.inc \theme_taxonomy_defaults_form()

Renders the settings form in a table.

File

./taxonomy_defaults.admin.inc, line 162
Administration forms for the taxonomy_defaults module

Code

function theme_taxonomy_defaults_form($variables) {
  $form = $variables['0'];
  drupal_add_css(drupal_get_path('module', 'taxonomy_defaults') . '/taxonomy_defaults.css', array(
    'preprocess' => FALSE,
  ));
  $output = '';
  foreach (node_type_get_types() as $type => $name) {
    if (isset($form[$type])) {
      $rowcount = 0;
      foreach (element_children($form[$type]) as $key) {
        $vocabtable[$rowcount][] = drupal_render($form[$type][$key]['name']);

        // Add the term selector - tags autocomplete field.
        if (isset($form[$type][$key]['tags'])) {
          $vocabtable[$rowcount][] = drupal_render($form[$type][$key]['hide_vocab']);
          $vocabtable[$rowcount][] = drupal_render($form[$type][$key]['tags']);
        }
        elseif (isset($form[$type][$key]['select'])) {
          $vocabtable[$rowcount][] = drupal_render($form[$type][$key]['hide_vocab']);
          $form[$type][$key]['select']['#title'] = '';
          $vocabtable[$rowcount][] = drupal_render($form[$type][$key]['select']);
        }
        else {
          $vocabtable[$rowcount][] = array(
            "data" => drupal_render($form[$type][$key]['msg']),
            "colspan" => 2,
          );
        }
        $rowcount++;
      }
      if ($rowcount) {
        $subtable = theme('table', array(
          'header' => array(
            t('Vocabulary'),
            t('Hide'),
            t('Default Terms'),
          ),
          'rows' => $vocabtable,
        ));
        $fieldset = array(
          '#title' => $name->name,
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
          '#value' => $subtable,
        );
        $output .= theme('fieldset', $fieldset);
      }
    }
    unset($vocabtable);
  }

  // Render remaining fields
  $output .= drupal_render_children($form);
  return $output;
}