You are here

function casetracker_case_type_form in Case Tracker 7.2

Generates the case type editing form.

File

./casetracker_case_type.inc, line 126
CaseTrackerCase type editing UI.

Code

function casetracker_case_type_form($form, &$form_state, $case_type, $op = 'edit') {
  if ($op == 'clone') {
    $case_type->label .= ' (cloned)';
    $case_type->type = '';
  }
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => $case_type->label,
    '#description' => t('The human-readable name of this case type.'),
    '#required' => TRUE,
    '#size' => 30,
  );

  // Machine-readable type name.
  $form['type'] = array(
    '#type' => 'machine_name',
    '#default_value' => isset($case_type->type) ? $case_type->type : '',
    '#maxlength' => 32,
    '#machine_name' => array(
      'exists' => 'casetracker_case_get_types',
      'source' => array(
        'label',
      ),
    ),
    '#description' => t('A unique machine-readable name for this case type. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $default_fields = array(
    t('Project reference: an Entity Reference type field to reference Case Tracker Projects.'),
    t('Description: a Long Text field to describe more about the cases.'),
    t('Status: a Text field with some predefined options.'),
    t('Priority: a Text field with some predefined options.'),
  );
  $form['default_fields'] = array(
    '#type' => 'markup',
    '#markup' => t('This case type will have the following default fields:') . theme('item_list', array(
      'items' => $default_fields,
    )),
  );
  $form['additional_fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Do you want to put some additional fields to this Case Type?'),
    '#description' => t('You will be able to create other fields any time through the Manage Fields page for this case type.'),
    '#options' => array(
      'field_casetracker_case_due_date' => t('Due date: a Date type field to be used on tasks that needs to predefine a due date.'),
      'field_casetracker_assigned_to' => t('Assigned To: an Entity Reference type field to reference site Users as the responsible for tasks.'),
    ),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save case type'),
    '#weight' => 40,
    '#suffix' => l(t('Cancel'), 'admin/structure/casetracker/case-types'),
  );
  return $form;
}