function tripal_chado_add_db_form_fields
3.x tripal_chado.db.inc | tripal_chado_add_db_form_fields(&$form, $form_state, $dbid = NULL) |
Fields commmon between the add/edit forms
2 calls to tripal_chado_add_db_form_fields()
- tripal_chado_db_add_form in tripal_chado/
includes/ tripal_chado.db.inc - Form to add new databases. Implements hook_form().
- tripal_chado_db_edit_form in tripal_chado/
includes/ tripal_chado.db.inc - Form to edit existing databases. Implements hook_form().
File
- tripal_chado/
includes/ tripal_chado.db.inc, line 138
Code
function tripal_chado_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;
$form['dbid'] = array(
'#type' => 'value',
'#value' => $dbid,
);
}
// 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. By default, Tripal will
combine this "URL prefix" with the database short name and
accession to create a link to the external site. But, you can
also use the tokens {db} and {accession} within the URL prefix
to specify exactly where the database short name and the accession
should be added. Tripal will substitute the actual values in
place of these tokens to create the link. (e.g. URL prefix: https://phytozome.jgi.doe.gov/phytomine/portal.do?externalid=PAC:{accession}).'),
'#default_value' => $default_urlprefix,
'#maxlength' => 255,
);
return $form;
}