function chado_project_form

2.x tripal_project.chado_node.inc chado_project_form(&$node, $form_state)
3.x tripal_project.chado_node.inc chado_project_form(&$node, $form_state)
1.x tripal_project.module chado_project_form(&$node, $form_state)

Implementation of hook_form().

This form takes the Project Title information and description from the user.

@parm $node The initialized node

@parm $form_state The state of the form, that has the user entered information that is neccessary for adding information to the project

Return value

$form An array as described by the Drupal Form API

Related topics

File

tripal_project/tripal_project.module, line 205
This file contains the basic functions needed for this drupal module. The drupal tripal_project module maps directly to the chado general module.

Code

function chado_project_form(&$node, $form_state) {
  $form = array();

  $project = $node->project;

  // get the project default values.  When this module was first created
  // the project description was incorrectly stored in the $node->body field.
  // It is better to store it in the Chado tables.  However, the 'description'
  // field of the project table is only 255 characters.  So, we are going
  // to follow the same as the project module and store the description in
  // the projectprop table and leave the project.description field blank.
  // however, for backwards compatibitily, we check to see if the description
  // is in the $node->body field. If it is we'll use that.  When the node is
  // edited the text will be moved out of the body and into the projectprop
  // table where it should belong.
  if ($node->body) {
    $project_description = $node->body;
  }
  else {
    $project_description = $node->project_description;
  }
  if (!$project_description) {
    $projectprop = tripal_project_get_property($project->project_id, 'project_description');
    $project_description = $projectprop->value;
  }

  // keep track of the project id if we have.  If we do have one then
  // this is an update as opposed to an insert.
  $form['project_id'] = array(
    '#type' => 'value',
    '#value' => $project->project_id,
  );

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Project Title'),
    '#description' => t('Please enter the title for this project. This appears at the top of the project page.'),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => 1
  );

  $form['project_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Project Description'),
    '#description' => t('A brief description of the project'),
    '#required' => TRUE,
    '#default_value' => $project_description,
    '#weight' => 5
  );

  return $form;

}