function chado_organism_form

2.x tripal_organism.chado_node.inc chado_organism_form($node, $form_state)
3.x tripal_organism.chado_node.inc chado_organism_form($node, $form_state)
1.x tripal_organism.module chado_organism_form($node, $param)

When editing or creating a new node of type 'chado_organism' we need a form. This function creates the form that will be used for this.

Related topics

File

tripal_organism/tripal_organism.module, line 443
tripal_organism Organism Module

Code

function chado_organism_form($node, $param) {
  $organism = $node->organism;

  // add in the comment since it is a text field and may not be included if too big
  $organism = tripal_core_expand_chado_vars($organism, 'field', 'organism.comment');

  // get form defaults
  $abbreviation = $node->abbreviation;
  if (!$abbreviation) {
    $abbreviation = $organism->abbreviation;
  }
  $genus = $node->genus;
  if (!$genus) {
    $genus = $organism->genus;
  }
  $species = $node->species;
  if (!$species) {
    $species = $organism->species;
  }
  $common_name = $node->common_name;
  if (!$common_name) {
    $common_name = $organism->common_name;
  }
  $description = $node->description;
  if (!$description) {
    $description = $organism->comment;
  }
  $organism_image = $node->organism_image;


  $form = array();
  $form['#attributes']['enctype'] = 'multipart/form-data';

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

  $form['abbreviation'] = array(
    '#type' => 'textfield',
    '#title' => t('Abbreviation'),
    '#required' => TRUE,
    '#default_value' => $organism->abbreviation,
    '#weight' => 3
  );
  $form['genus'] = array(
    '#type' => 'textfield',
    '#title' => t('Genus'),
    '#required' => TRUE,
    '#default_value' => $organism->genus,
    '#weight' => 1
  );
  $form['species'] = array(
    '#type' => 'textfield',
    '#title' => t('Species'),
    '#required' => TRUE,
    '#default_value' => $organism->species,
    '#weight' => 2
  );
  $form['common_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Common Name'),
    '#required' => TRUE,
    '#default_value' => $organism->common_name,
    '#weight' => 4
  );
  $form['description'] = array(
    '#type' => 'textarea',
    '#rows' => 15,
    '#title' => t('Description'),
    '#required' => TRUE,
    '#default_value' => $organism->comment,
    '#weight' => 5
  );
  $form['organism_image'] = array(
    '#type' => 'file',
    '#title' => t('Organism Image'),
    '#description' => 'Add an image for this organism',
    '#weight' => 6
  );
  return $form;
}