function chado_project_validate
2.x tripal_project.chado_node.inc | chado_project_validate($node, $form, &$form_state) |
3.x tripal_project.chado_node.inc | chado_project_validate($node, |
1.x tripal_project.module | chado_project_validate($node) |
validates submission of form when adding or updating a project node
Related topics
File
- tripal_project/
tripal_project.module, line 264 - 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_validate($node) {
$project = 0;
// check to make sure the name on the project is unique
// before we try to insert into chado.
if ($node->project_id) {
$sql = "SELECT * FROM {project} WHERE name = '%s' AND NOT project_id = %d";
$project = db_fetch_object(chado_query($sql, $node->title, $node->project_id));
}
else {
$sql = "SELECT * FROM {project} WHERE name = '%s'";
$project = db_fetch_object(chado_query($sql, $node->title));
}
if ($project) {
form_set_error('title', t('The unique project name already exists. Please choose another'));
}
}