--- product.module.old	2005-12-29 14:06:01.000000000 -0600
+++ product.module	2005-12-29 13:59:50.000000000 -0600
@@ -107,21 +107,52 @@
  */
 function product_form(&$node) {
   $output = '';
-  $output .= form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
-
-  $output .= form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE);
+  $output .= $form['title'] = array(
+  '#type' => 'textfield',
+  '#title' => t('Title'),
+  '#default_value' => $node->title,
+  '#size' => 60,
+  '#maxlength' => 128,
+  '#description' => NULL,
+  '#attributes' => NULL,
+  '#required' => TRUE,
+);
+
+  $output .= $form['title'] = array(
+  '#type' => 'textfield',
+  '#title' => t('Title'),
+  '#default_value' => $node->title,
+  '#size' => 60,
+  '#maxlength' => 128,
+  '#description' => NULL,
+  '#attributes' => NULL,
+  '#required' => TRUE,
+);
 
   if (function_exists('taxonomy_node_form')) {
     $output .= implode("", taxonomy_node_form('product', $node));
   }
 
-  $output .= form_textarea(t('Description'), 'body', $node->body, 60, 10, t('Provide the product details to display on the page.'));
+  $output .= $form['body'] = array(
+  '#type' => 'textarea',
+  '#title' => t('Description'),
+  '#default_value' => $node->body,
+  '#cols' => 60,
+  '#rows' => 10,
+  '#description' => t('Provide the product details to display on the page.'),
+);
   $output .= filter_form('format', $node->format);
   $output .= product_get_base_form_elements($node);
-  $output .= form_hidden('ptype', $node->ptype);
+  $output .= $form['ptype'] = array(
+  '#type' => 'hidden',
+  '#value' => $node->ptype,
+);
   $bool = module_invoke($node->ptype, 'productapi', $node, 'is_shippable');
   if (module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $node, 'per_product') && $bool[0]) {
-    $output .= form_hidden('per_product_shipping', 1);
+    $output .= $form['per_product_shipping'] = array(
+  '#type' => 'hidden',
+  '#value' => 1,
+);
     $output .= module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $node, 'per_product_form');
   }
   $output .= module_invoke($node->ptype, 'productapi', $node, 'form');
@@ -288,39 +319,60 @@
         }
         else {
           $output = product_get_base_form_elements($edit);
-          $output .= form_hidden('ptype', $edit->ptype);
+          $output .= $form['ptype'] = array(
+  '#type' => 'hidden',
+  '#value' => $edit->ptype,
+);
           $output .= module_invoke($edit->ptype, 'productapi', $edit, 'form');
 
           if ($edit->ptype && !form_get_errors()) {
-            $output .= form_submit(t('Update product'));
-            $output .= form_submit(t('Remove product'));
+            $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Update product'),
+);
+            $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Remove product'),
+);
           }
           else {
             $output .= product_form_product_types();
           }
-          $output = form($output);
+          $output = $output = drupal_get_form('form_product_types', $form);
         }
         drupal_set_title(t('%node-title (product)', array('%node-title' => $node->title)));
         break;
 
       default:
         $output = product_get_base_form_elements($edit);
-        $output .= form_hidden('ptype', $edit->ptype);
+        $output .= $form['ptype'] = array(
+  '#type' => 'hidden',
+  '#value' => $edit->ptype,
+);
         $bool = module_invoke($edit->ptype, 'productapi', $edit, 'is_shippable');
         if (module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $edit, 'per_product') && $bool[0]) {
-          $output .= form_hidden('per_product_shipping', 1);
+          $output .= $form['per_product_shipping'] = array(
+  '#type' => 'hidden',
+  '#value' => 1,
+);
           $output .= module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $edit, 'per_product_form');
         }
         $output .= module_invoke($edit->ptype, 'productapi', $edit, 'form');
 
         if ($node->ptype) {
-          $output .= form_submit(t('Update product'));
-          $output .= form_submit(t('Remove product'));
+          $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Update product'),
+);
+          $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Remove product'),
+);
         }
         else {
           $output .= product_form_product_types();
         }
-        $output = form($output);
+        $output = $output = drupal_get_form('product_form_product_types', $form);
         drupal_set_title(t('%node-title (product)', array('%node-title' => $node->title)));
     }
 
@@ -488,21 +540,59 @@
     $ptype = module_invoke($edit->ptype, 'productapi', $edit, 'wizard_select');
     $output .= t('<p><b>Product type:</b> %ptype</p>', array('%ptype' => $ptype[$edit->ptype]));
   }
-  $output .= form_textfield(t('Price'), 'price', $edit->price, 25, 50, t('How much does this product retail for? Note: This price may be different from the selling price due to price adjustments elsewhere.'). $help);
-  if (variable_get('payment_recurring', 0)) {
+  $output .=$form['price'] = array(
+  '#type' => 'textfield',
+  '#title' => t('Price'),
+  '#default_value' => $edit->price,
+  '#size' => 25,
+  '#maxlength' => 50,
+  '#description' => t('How much does this product retail for? Note: This price may be different from the selling price due to price adjustments elsewhere.'). $help,
+);  if (variable_get('payment_recurring', 0)) {
     $interval = drupal_map_assoc(range(0, 31));
     $interval[0] = '--';
     $unit = array(0 => t('-please choose-'), 'D' => t('Day(s)'), 'W' => t('Week(s)'), 'M' => t('Month(s)'), 'Y' => t('Year(s)'));
 
-    $group = form_select(t('Interval'), 'price_interval', $edit->price_interval, $interval);
-    $group .= form_select(t('Unit'), 'price_unit', $edit->price_unit, $unit);
+    $group = $form['price_interval'] = array(
+  '#type' => 'select',
+  '#title' => t('Interval'),
+  '#default_value' => $edit->price_interval,
+  '#options' => $interval,
+);
+    $group .= $form['price_unit'] = array(
+  '#type' => 'select',
+  '#title' => t('Unit'),
+  '#default_value' => $edit->price_unit,
+  '#options' => $unit,
+);
     $interval[-1] = t('unlimited');
     //$interval[0] = 0;
-    $group .= form_select(t('Number of payments cycles'), 'price_cycle', (isset($edit->price_cycle)) ? $edit->price_cycle : -1, $interval, t('Select the number of recurring payment cycles this product has.'));
-    $output .= form_group(t('Billing cycle length'), $group);
-  }
-  $output .= form_textfield(t('SKU'), 'sku', $edit->sku, 25, 50, t('If you have an unique identifier for this product from another system or database, enter that here. This is optional, as system IDs are automatically created for each product.'));
-  $output .= form_radios(t("'Add to cart' link"), 'hide_cart_link', $edit->hide_cart_link, array(t("Visible"), t("Hidden")), t("Choose whether or not you want the 'Add to cart' link visible for this product."));
+    $group .= $form['price_cycle'] = array(
+  '#type' => 'select',
+  '#title' => t('Number of payments cycles'),
+  '#default_value' => (isset($edit->price_cycle)) ? $edit->price_cycle : -1,
+  '#options' => $interval,
+  '#description' => t('Select the number of recurring payment cycles this product has.'),
+);
+    $output .= $form[] = array(
+  '#type' => 'fieldset',
+  '#title' => t('Billing cycle length'),
+);
+  }
+  $output .= $form['sku'] = array(
+  '#type' => 'textfield',
+  '#title' => t('SKU'),
+  '#default_value' => $edit->sku,
+  '#size' => 25,
+  '#maxlength' => 50,
+  '#description' => t('If you have an unique identifier for this product from another system or database, enter that here. This is optional, as system IDs are automatically created for each product.'),
+);
+  $output .= $form['hide_cart_link'] = array(
+  '#type' => 'radios',
+  '#title' => t("'Add to cart' link"),
+  '#default_value' => $edit->hide_cart_link,
+  '#options' => array(t("Visible"), t("Hidden")),
+  '#description' => t("Choose whether or not you want the 'Add to cart' link visible for this product."),
+);
 
   return $output;
 }
@@ -521,7 +611,10 @@
   $node_form = preg_replace("'</?(input type=\"submit\").*?>'", '', $node_form);
   $node_form .= product_form_product_types();
 
-  return form($node_form, 'post', null, array('id' => 'node-form'));
+  return $form['#method'] = 'post';
+$form['#action'] = null;
+$form['#attributes'] = array('id' => 'node-form');
+$output = drupal_get_form('node_form', $form);
 }
 
 function product_form_product_types() {
@@ -537,8 +630,17 @@
   else {
     $ptypes_display = $ptypes_display + $ptypes;
   }
-  $output = form_select(t('Type of product to create'), 'ptype', $edit->ptype, $ptypes_display, t('You cannot change the product type once it\'s created.'));
-  $output .= form_submit(t('Continue to product details'));
+  $output = $form['ptype'] = array(
+  '#type' => 'select',
+  '#title' => t('Type of product to create'),
+  '#default_value' => $edit->ptype,
+  '#options' => $ptypes_display,
+  '#description' => t('You cannot change the product type once it\'s created.'),
+);
+  $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Continue to product details'),
+);
 
   return $output;
 }
@@ -555,15 +657,23 @@
     /* I'd like to have more control than this, but we have no idea what will be tacked on by nodeapi hooks. */
     foreach ($edit as $key => $value) {
       if (!is_array($value) && !is_object($value)) {
-        $output .= form_hidden($key, $value);
+        $output .= $form[$key] = array(
+  '#type' => 'hidden',
+  '#value' => $value,
+);
       }
       else {
         /* In case we need to pass along any data that's an array. */
         $pass_array[$key] = $value;
       }
     }
-    $output .= form_hidden('pass_array', serialize($pass_array));
-    $output .= ($edit->taxonomy) ? form_hidden('taxonomy', serialize($edit->taxonomy)) : '';
+    $output .= $form['pass_array'] = array(
+  '#type' => 'hidden',
+  '#value' => serialize($pass_array),
+);
+    $output .= ($edit->taxonomy) ? $form['taxonomy'] = array(
+  '#type' => 'hidden',
+  '#value' => serialize($edit->taxonomy)) : '';
     $output .= '<strong>'. t('Price') . ': </strong>'. payment_format($edit->price) . product_recurring_nice_string($edit) . '<br />';
     if ($edit->sku) {
       $output .= '<strong>'. t('<acronym title="Stock-Keeping Unit">SKU</acronym>') . ': </strong>'. $edit->sku . '<br />';
@@ -577,17 +687,26 @@
     // have the per product shipping option enabled.
     $bool = module_invoke($edit->ptype, 'productapi', $edit, 'is_shippable');
     if (module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $edit, 'per_product') && $bool[0]) {
-      $output .= form_hidden('per_product_shipping', 1);
+      $output .= $form['per_product_shipping'] = array(
+  '#type' => 'hidden',
+  '#value' => 1,
+);
       $output .= module_invoke(variable_get('shipping_method', 'none'), 'shippingapi', $edit, 'per_product_form');
     }
 
     $output .= module_invoke($edit->ptype, 'productapi', $edit, 'form', $error);
 
     if (db_result(db_query('SELECT COUNT(nid) FROM {ec_product} WHERE nid = %d', $edit->nid))) {
-      $output .= form_submit(t('Update this product'));
+      $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Update this product'),
+);
     }
     else {
-      $output .= form_submit(t('Create product'));
+      $output .= $form[] = array(
+  '#type' => 'submit',
+  '#value' => t('Create product'),
+);
     }
   }
   else {
@@ -595,7 +714,7 @@
     $output .= product_wizard_form($edit);
   }
 
-  return form($output);
+  return $output = drupal_get_form('product_wizard_form', $form);
 }
 
 function product_form_validate(&$edit) {
@@ -1063,4 +1182,4 @@
 function product_fields($table = 'ec_product') {
   return array('nid', 'sku', 'price', 'is_recurring', 'price_interval', 'price_unit', 'price_cycle', 'auto_charge', 'ptype', 'hide_cart_link');
 }
-?>
+?>
\ No newline at end of file
