You are here

function casetracker_form_alter in Case Tracker 6

Same name and namespace in other branches
  1. 5 casetracker.module \casetracker_form_alter()
  2. 7 casetracker.module \casetracker_form_alter()

Implementation of hook_form_alter().

File

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

Code

function casetracker_form_alter(&$form, &$form_state, $form_id) {
  if (!empty($form['#node'])) {
    $node = $form['#node'];

    // Add case options to our basic case type.
    if (casetracker_is_case($node->type)) {
      $count = count(casetracker_project_options());
      if ($count == 0) {
        drupal_set_message(t('You must create a project before adding cases.'), 'error');
        return;
      }
      else {
        $default_project = null;
        if (!isset($form['#node']->nid) && is_numeric(arg(3))) {
          $default_project = arg(3);
        }
        casetracker_case_form_common($form, $default_project);
      }
    }
  }
}