function tripal_stock_edit_ALL_properties_form

1.x tripal_stock-properties.inc tripal_stock_edit_ALL_properties_form($form_state, $node)

Implements Hook_form(): Handles adding of Properties & Synonyms to Stocks

Related topics

2 string references to 'tripal_stock_edit_ALL_properties_form'
tripal_stock_edit_ALL_properties_page in tripal_stock/includes/tripal_stock-properties.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-properties.inc, line 190
@todo Add file header description

Code

function tripal_stock_edit_ALL_properties_form($form_state, $node) {
  $form = array();

  // Add properties and synonyms
  $node = tripal_core_expand_chado_vars($node, 'table', 'stockprop');

  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $node->nid
  );

  $i = 0;
  if (!$node->stock->stockprop) {
    $node->stock->stockprop = array();
  }
  elseif (!is_array($node->stock->stockprop)) {
    $node->stock->stockprop = array($node->stock->stockprop);
  }
  if (sizeof($node->stock->stockprop) != 0) {
    foreach ($node->stock->stockprop as $property) {
      $i++;
      $form["num-$i"] = array(
        '#type' => 'item',
        '#value' => $i . '.'
      );

      $form["id-$i"] = array(
        '#type' => 'hidden',
        '#value' => $property->stockprop_id
      );

      $prop_type_options = tripal_cv_get_cvterm_options(variable_get('chado_stock_prop_types_cv', 'null'));
      ksort($prop_type_options);
      $form["type-$i"] = array(
        '#type' => 'select',
        //'#title' => t('Type of Property'),
        '#options' => $prop_type_options,
        '#default_value' => $property->type_id->cvterm_id
      );

      $form["value-$i"] = array(
        '#type' => 'textfield',
        //'#title' => t('Value'),
        '#default_value' => $property->value
      );

      $form["submit-$i"] = array(
        '#type' => 'submit',
        '#value' => t("Delete #$i")
      );

    }
  } //end of foreach property

  $form['num_properties'] = array(
    '#type' => 'hidden',
    '#value' => $i
  );

  $form["submit-edits"] = array(
    '#type' => 'submit',
    '#value' => t('Update Properties')
  );

  return $form;
}