function tripal_stock_edit_ALL_relationships_form
1.x tripal_stock-relationships.inc | tripal_stock_edit_ALL_relationships_form($form_state, $node) |
Implements Hook_form()
Related topics
2 string references to 'tripal_stock_edit_ALL_relationships_form'
- tripal_stock_edit_ALL_relationships_page in tripal_stock/
includes/ tripal_stock-relationships.inc - tripal_stock_theme in tripal_stock/
tripal_stock.module - Implements hook_theme(): Register themeing functions for this module
File
- tripal_stock/
includes/ tripal_stock-relationships.inc, line 216 - @todo Add file header description
Code
function tripal_stock_edit_ALL_relationships_form($form_state, $node) {
$form = array();
// All Stock Relationships
$node = tripal_core_expand_chado_vars($node, 'table', 'stock_relationship');
// compile all relationships into one variable
$relationships = array();
if (is_array($node->stock->stock_relationship->subject_id)) {
foreach ($node->stock->stock_relationship->subject_id as $r) {
$relationships[$r->stock_relationship_id] = $r;
}
}
elseif (is_object($node->stock->stock_relationship->subject_id)) {
$relationships[$node->stock->stock_relationship->subject_id->stock_relationship_id] = $node->stock->stock_relationship->subject_id;
}
if (is_array($node->stock->stock_relationship->object_id)) {
foreach ($node->stock->stock_relationship->object_id as $r) {
$relationships[$r->stock_relationship_id] = $r;
}
}
elseif (is_object($node->stock->stock_relationship->object_id)) {
$relationships[$node->stock->stock_relationship->object_id->stock_relationship_id] = $node->stock->stock_relationship->object_id;
}
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid
);
$form['r_stock_uniquename'] = array(
'#type' => 'hidden',
'#value' => $node->stock->uniquename
);
$i = 0;
if (sizeof($relationships) != 0) {
foreach ($relationships as $r) {
$i++;
$form["num-$i"] = array(
'#type' => 'item',
'#value' => $i . '.'
);
$form["id-$i"] = array(
'#type' => 'hidden',
'#value' => $r->stock_relationship_id
);
//Enter relationship specific fields
if ($node->stock->stock_id != $r->subject_id->stock_id) {
$default = $r->subject_id->uniquename;
$description = l($r->subject_id->name, 'node/' . $r->subject_id->nid);
}
else {
$default = $node->stock->uniquename;
$description = 'Current Stock';
}
$form["subject_id-$i"] = array(
'#type' => 'textfield',
//'#title' => t('Subject'),
'#required' => TRUE,
'#size' => 30,
'#default_value' => $default,
'#description' => t('%description', array('%description' => $description)),
);
$type_options = tripal_cv_get_cvterm_options(variable_get('chado_stock_relationship_cv', 'null'));
ksort($type_options);
$form["type_id-$i"] = array(
'#type' => 'select',
//'#title' => t('Type of Relationship'),
'#options' => $type_options,
'#required' => TRUE,
'#default_value' => $r->type_id->cvterm_id
);
if ($node->stock->stock_id != $r->object_id->stock_id) {
$default = $r->object_id->uniquename;
$description = l($r->object_id->name, 'node/' . $r->object_id->nid);
}
else {
$default = $node->stock->uniquename;
$description = 'Current Stock';
}
$form["object_id-$i"] = array(
'#type' => 'textfield',
//'#title' => t('Object'),
'#required' => TRUE,
'#size' => 30,
'#default_value' => $default,
'#description' => $description
);
$form["submit-$i"] = array(
'#type' => 'submit',
'#value' => t("Delete #$i")
);
}
} //end of foreach relationship
$form['num_relationships'] = array(
'#type' => 'hidden',
'#value' => $i
);
$form["submit-edits"] = array(
'#type' => 'submit',
'#value' => t('Update Relationships')
);
return $form;
}