function tripal_db_form_fields_validate

2.x tripal_db.admin.inc tripal_db_form_fields_validate($form, &$form_state)

Generic form validation for shared fields of both the edit and add forms

Related topics

2 calls to tripal_db_form_fields_validate()
tripal_db_db_add_form_validate in tripal_db/includes/tripal_db.admin.inc
Validation fucntion for tripal_db_db_add_form
tripal_db_db_edit_form_validate in tripal_db/includes/tripal_db.admin.inc
Validation fucntion for tripal_db_db_edit_form

File

tripal_db/includes/tripal_db.admin.inc, line 222
Provide administration of dbs & dbxrefs

Code

function tripal_db_form_fields_validate($form, &$form_state) {
  $name = array_key_exists('name', $form_state['values']) ? trim($form_state['values']['name']) : '';
  $desc = array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
  $url = array_key_exists('url', $form_state['values']) ? trim($form_state['values']['url']) : '';
  $urlp = array_key_exists('urlprefix', $form_state['values']) ? trim($form_state['values']['urlprefix']) : '';
  $dbid = array_key_exists('dbid', $form_state['values']) ? trim($form_state['values']['dbid']) : '';

  // make sure the database name is unique
  $values = array('name' => $name);
  $results = chado_select_record('db', array('db_id'), $values);
  if (count($results) > 0 and $results[0]->db_id != $dbid) {
    form_set_error('name', 'The database name must be unique');
  }
}