function chado_featuremap_validate

2.x tripal_featuremap.chado_node.inc chado_featuremap_validate($node, $form, &$form_state)
3.x tripal_featuremap.chado_node.inc chado_featuremap_validate($node, $form, &$form_state)
1.x tripal_featuremap.form.inc chado_featuremap_validate($node, &$form)

validates submission of form when adding or updating a map node

Related topics

File

tripal_featuremap/includes/tripal_featuremap.form.inc, line 115

Code

function chado_featuremap_validate($node, &$form) {
  $name = trim($node->title);
  $featuremap_id = trim($node->featuremap_id);
  $unittype_id = trim($node->unittype_id);
  $description = trim($node->description);
  $num_properties = $node->num_properties;
  $num_new = $node->num_new;

  $featuremap = 0;
  // check to make sure the unique name on the map is unique
  // before we try to insert into chado. If this is an update then we will
  // have a featuremap_id, therefore we want to look for another map with this
  // name but with a different featuremap_id. If this is an insert, just look
  // for a case where the name already exists.
  if ($node->featuremap_id) {
    $sql = "
      SELECT * FROM {featuremap} 
      WHERE name = '%s' AND NOT featuremap_id = %d
    ";
    $featuremap = db_fetch_object(chado_query($sql, $node->title, $node->featuremap_id));
  }
  else {
    $sql = "SELECT * FROM {featuremap} WHERE name = '%s'";
    $featuremap = db_fetch_object(chado_query($sql, $node->title));
  }
  if ($featuremap) {
    form_set_error('name', t('The unique map name already exists. Please choose another'));
  }

}