function tripal_db_add_db_form_fields

2.x tripal_db.admin.inc tripal_db_add_db_form_fields(&$form, $form_state, $dbid = NULL)

Fields commmon between the add/edit forms

Related topics

2 calls to tripal_db_add_db_form_fields()
tripal_db_db_add_form in tripal_db/includes/tripal_db.admin.inc
Form to add new databases. Implements hook_form().
tripal_db_db_edit_form in tripal_db/includes/tripal_db.admin.inc
Form to edit existing databases. Implements hook_form().

File

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

Code

function tripal_db_add_db_form_fields(&$form, $form_state, $dbid = NULL) {

  $default_db = '';
  $default_desc = '';
  $default_url = '';
  $default_urlprefix = '';

  // get the default values from the database first
  if ($dbid) {
    $values = array('db_id' => $dbid);
    $result = chado_select_record('db', array('*'), $values);
    $db = $result[0];
    $default_db = $db->name;
    $default_desc = $db->description;
    $default_url = $db->url;
    $default_urlprefix = $db->urlprefix;
  }

  // add a fieldset for the Drupal Schema API
  $form['fields'] = array(
    '#type' => 'fieldset',
    '#title' => 'Database Details',
    '#collapsible' => 0,
  );

  $form['fields']['name'] = array(
    '#type' => 'textfield',
    '#title' => t("Database Name"),
    '#description' => t('Please enter the name for this external database.'),
    '#required' => TRUE,
    '#default_value' => $default_db,
    '#maxlength' => 255,
  );

  $form['fields']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#description' => t('Please enter a description for this database'),
    '#default_value' => $default_desc,
    '#maxlength' => 255,
  );
  $form['fields']['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),
    '#description' => t('Please enter the web address for this database.'),
    '#default_value' => $default_url,
    '#maxlength' => 255,
  );
  $form['fields']['urlprefix'] = array(
    '#type' => 'textfield',
    '#title' => t('URL prefix'),
    '#description' => t('Tripal can provide links to external databases when accession numbers or unique identifiers are known.  Typically, a database will provide a unique web address for each accession and the accession usually is the last component of the page address.  Please enter the web address, minus the accession number for this database.  When an accession number is present, Tripal will combine this web address with the accession and provide a link to the external site.'),
    '#default_value' => $default_urlprefix,
    '#maxlength' => 255,
  );
  return $form;
}