You are here

function casetracker_project_edit_form in Case Tracker 7.2

Form callback: create or edit a casetracker_project.

Parameters

$project: The casetracker_project object to edit or for a create form an empty casetracker_project object with only a casetracker_project type defined.

1 string reference to 'casetracker_project_edit_form'
casetracker_project_form_wrapper in ./casetracker_project.inc
Form callback wrapper: create or edit a casetracker_project.

File

./casetracker_project.inc, line 185
This file concentrates all general functionality related to Projects in Case Tracker, leaving to the other files in /admin the stuff related to CRUD and structural configuration

Code

function casetracker_project_edit_form($form, &$form_state, $project) {
  casetracker_project_set_breadcrumb();
  if (!empty($project->pid)) {
    drupal_set_title(t('@project (editing project info)', array(
      '@project' => $project->title,
    )));
  }

  // Add the default field elements.
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => isset($project->title) ? $project->title : '',
    '#maxlength' => 255,
    '#required' => TRUE,
    '#weight' => -25,
  );

  // Add the field related form elements.
  $form_state['casetracker_project'] = $project;
  field_attach_form('casetracker_project', $project, $form, $form_state);
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 400,
  );

  // We add the form's #submit array to this button along with the actual submit
  // handler to preserve any submit handlers added by a form callback_wrapper.
  $submit = array();
  if (!empty($form['#submit'])) {
    $submit += $form['#submit'];
  }
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save project'),
    '#submit' => $submit + array(
      'casetracker_project_edit_form_submit',
    ),
  );

  /**
   * There is some bug that in this module code that makes the submit callback
   * being ignored
   */

  // Show Delete button if the project.is being edited
  //  if (!empty($project->pid) && casetracker_project_access('edit', $project)) {
  //    $form['actions']['delete'] = array(
  //      '#type' => 'submit',
  //      '#value' => t('Delete'),
  //      '#submit' => array('casetracker_project_form_submit_delete'),
  //    );
  //  }
  // We append the validate handler to #validate in case a form callback_wrapper
  // is used to add validate handlers earlier.
  $form['#validate'][] = 'casetracker_project_edit_form_validate';
  return $form;
}