function tripal_cv_cv_edit_form
2.x tripal_cv.cv_form.inc | tripal_cv_cv_edit_form($form, &$form_state) |
3.x tripal_chado.cv.inc | tripal_cv_cv_edit_form($form, &$form_state) |
Provides the actual "Select CV" form on the Update/Delete Controlled Vocabulary page. This form also triggers the edit javascript @todo Modify this form to use Drupal AJAX
2 string references to 'tripal_cv_cv_edit_form'
- tripal_chado_menu in tripal_chado/
tripal_chado.module - Implements hook_menu().
- tripal_cv_menu in legacy/
tripal_cv/ tripal_cv.module - Implements hook_menu(). Registers all menu items associated with this module
File
- tripal_chado/
includes/ tripal_chado.cv.inc, line 66
Code
function tripal_cv_cv_edit_form($form, &$form_state) {
// get the cv_d if form was submitted via AJAX
$cv_id = 0;
if (array_key_exists('values', $form_state)) {
$cv_id = $form_state['values']['cv_id'];
}
elseif (isset($form_state['build_info']['args'][0])) {
$cv_id = $form_state['build_info']['args'][0];
}
// get a list of db from chado for user to choose
$sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
$results = chado_query($sql);
$cvs = array();
$cvs[] = 'Select a vocabulary';
foreach ($results as $cv) {
$cvs[$cv->cv_id] = $cv->name;
}
$form['cv_id'] = array(
'#title' => t('Controlled Vocabulary Name'),
'#type' => 'select',
'#options' => $cvs,
'#ajax' => array(
'callback' => 'tripal_cv_edit_form_ajax',
'wrapper' => 'cv-edit-div',
'effect' => 'fade',
'event' => 'change',
'method' => 'replace',
),
'#default_value' => $cv_id,
);
// if we don't have a db_id then we can return the form, otherwise
// add in the other fields
if ($cv_id) {
tripal_cv_add_cv_form_fields($form, $form_state, $cv_id);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$form['delete'] = array(
'#type' => 'markup',
'#markup' => l('delete', 'admin/tripal/loaders/chado_vocabs/chado_cv/delete/' . $cv_id),
);
}
else {
// if we don't have a dbid then this is the first time the form has
// benn loaded and we need to create the div where ajax replacement elements get stored
$form['div_replace'] = array(
'#type' => 'item',
'#prefix' => '<div id="cv-edit-div">',
'#suffix' => '</div>',
);
}
return $form;
}