You are here

function theme_casetracker_case_form_common in Case Tracker 7

Same name and namespace in other branches
  1. 6 casetracker.module \theme_casetracker_case_form_common()

Theme function for cleaning up the casetracker common form.

1 theme call to theme_casetracker_case_form_common()
casetracker_case_form_common in ./casetracker.module
Common form elements for cases, generic enough for use either in a full node display, or in comment displays and updating. Default values are calculated based on an existing $form['nid']['#value'].

File

./casetracker.module, line 1075
Enables the handling of projects and their cases.

Code

function theme_casetracker_case_form_common($form) {
  $form = $form['form'];
  drupal_add_css(drupal_get_path('module', 'casetracker') . '/casetracker.css');
  $output = '';
  $output .= drupal_render($form['pid']);
  $output .= drupal_render($form['case_title']);
  if ($form['assign_to']['#type'] == 'radios') {
    if ($form['assign_to']['#access']) {
      $header = array_fill(0, 5, array());
      $header[0] = $form['assign_to']['#title'];
      $radios = array();
      foreach (element_children($form['assign_to']) as $id) {
        $radios[] = drupal_render($form['assign_to'][$id]);
      }
      $radios = array_chunk($radios, 5);
      end($radios);
      $last =& $radios[key($radios)];
      $last = array_pad($last, 5, array());
      $output .= theme('table', array(
        'header' => $header,
        'rows' => $radios,
        'attributes' => array(
          'class' => array(
            'casetracker-assign-to',
          ),
        ),
      ));
    }
    drupal_render($form['assign_to']);
  }
  else {
    $output .= drupal_render($form['assign_to']);
  }
  $row = array();
  foreach (element_children($form) as $id) {
    if (!in_array($id, array(
      'pid',
      'case_title',
      'assign_to',
    ))) {
      $row[] = drupal_render($form[$id]);
    }
  }
  $rows = array(
    $row,
  );
  $output .= theme('table', array(
    'header' => array(),
    'rows' => $rows,
  ));

  // TODO commenting the bellow line removes possible infinite
  // recursion/iteration on add case form. WHY?
  return $output;
}