Index: openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl,v
diff -u -r1.1.2.3 -r1.1.2.4
--- openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl	18 Feb 2005 18:33:26 -0000	1.1.2.3
+++ openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl	21 Feb 2005 18:56:27 -0000	1.1.2.4
@@ -28,28 +28,25 @@
 } {
     upvar $array local
 
-    dtype::get_attributes -name $object_type attributes
-    db_1row select_table_name {}
+    set attributes_list [dtype::get_attributes -name $object_type -list t attributes]
 
     set columns [list]
 
-    set size [template::multirow size attributes]
-    for {set i 1} {$i <= $size} {incr i} {
-        template::multirow get attributes $i
-
-        switch $attributes(datatype) {
+    foreach attribute_info $attributes_list {
+        foreach {name pretty_name attribute_id datatype table_name column_name default_value min_n_values max_n_values static_p} $attribute_info break
+        switch $datatype {
               date -
               timestamp -
               time_of_day {
                   set format "'YYYY-MM-DD HH24:MI:SS'"
-                  lappend columns "to_char($attributes(column_name), $format) as $attributes(name)"
+                  lappend columns "to_char($column_name, $format) as $name"
               }
               default {
-                  lappend columns "$attributes(column_name) as $attributes(name)"
+                  lappend columns "$column_name as $name"
               }
         }
     }
-
+    db_1row select_table_name {}
     set columns [join $columns ", "]
     db_0or1row select_object {} -column_array local
 }
@@ -129,43 +126,50 @@
     {-name:required}
     {-start_with "acs_object"}
     {-storage_types "type_specific"}
+    {-list "f"}
     multirow
 } {
     Gets all the attributes of a object_type.  Optionally
     it can return only those attributes after a given name.
 } {
-    template::multirow create $multirow \
-        name \
-        pretty_name \
-        attribute_id \
-        datatype \
-        table_name \
-        column_name \
-        default_value \
-        min_n_values \
-        max_n_values \
-        storage \
-        static_p
 
     set attributes [dtype::get_attributes_list \
         -name $name \
         -start_with $start_with \
         -storage_types $storage_types]
 
-    foreach attribute $attributes {
-        template::multirow append $multirow \
-            [lindex $attribute 0] \
-            [lindex $attribute 1] \
-            [lindex $attribute 2] \
-            [lindex $attribute 3] \
-            [lindex $attribute 4] \
-            [lindex $attribute 5] \
-            [lindex $attribute 6] \
-            [lindex $attribute 7] \
-            [lindex $attribute 8] \
-            [lindex $attribute 9] \
-            [lindex $attribute 10]
-    }
+    if {!$list} {
+    
+        template::multirow create $multirow \
+            name \
+            pretty_name \
+            attribute_id \
+            datatype \
+            table_name \
+            column_name \
+            default_value \
+            min_n_values \
+            max_n_values \
+            storage \
+            static_p
+        
+        foreach attribute $attributes {
+            template::multirow append $multirow \
+                [lindex $attribute 0] \
+                [lindex $attribute 1] \
+                [lindex $attribute 2] \
+                [lindex $attribute 3] \
+                [lindex $attribute 4] \
+                [lindex $attribute 5] \
+                [lindex $attribute 6] \
+                [lindex $attribute 7] \
+                [lindex $attribute 8] \
+                [lindex $attribute 9] \
+                [lindex $attribute 10]
+        }
+    } else {
+        return $attributes
+    } 
 }
 
 ad_proc -private dtype::get_attributes_list {
Index: openacs-4/packages/dynamic-types/tcl/form-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dynamic-types/tcl/form-procs.tcl,v
diff -u -r1.2.2.3 -r1.2.2.4
--- openacs-4/packages/dynamic-types/tcl/form-procs.tcl	18 Feb 2005 17:03:11 -0000	1.2.2.3
+++ openacs-4/packages/dynamic-types/tcl/form-procs.tcl	21 Feb 2005 18:56:27 -0000	1.2.2.4
@@ -146,9 +146,6 @@
     Process a dynamic type form submission created by a function such as
     dtype::form::add_elements.  
 
-    @param object_id the object represented in the form.  If set the form is
-           assumed to be an edit form, otherwise it is assumed to be an object
-           create form
     @param object_type the object type whose metadata will define the form
     @param dform specifies the stored object form used
     @param dforms specifies the stored object form to use for particular object 
@@ -278,7 +275,7 @@
     # -defaults { context_id 1234 } argument
     
     foreach type $types {
-
+        set missing_columns ""
         # Add attributes to $columns and associated bind variables to $values 
         # for each type
         if {[info exists type_dforms($type)]} {
@@ -373,17 +370,17 @@
             if {$new_p} { 
                 db_dml insert_statement "
                     insert into ${type_info(table_name)}i 
-                    (item_id, [join $columns ", "])
+                    ([join [concat "item_id" "revision_id" $columns] ", "])
                     values 
-                    (:item_id, [join $values ", "])"
+                    ([join [concat ":item_id" ":object_id" $values] ", "])"
             } else { 
                 set latest_revision [content::item::get_latest_revision -item_id $item_id]
 
                 db_dml insert_statement "
                     insert into ${type_info(table_name)}i 
-                    (item_id, [join [concat $columns $missing_columns] ", "])
-                    select item_id, 
-                    [join [concat $values $missing_columns] ", "]
+                    ([join [concat "item_id" "revision_id" $columns $missing_columns] ", "])
+                    select  
+                    [join [concat ":item_id" ":object_id" $values $missing_columns] ", "]
                     from ${type_info(table_name)}i
                     where revision_id = $latest_revision"
             }
@@ -497,10 +494,10 @@
         if {![template::util::is_true $widgets(is_required)]} {
           append element_create_cmd " -optional"
         }
-
+        
         if {![string equal $widgets(widget) file]} {
             # Append the initial value
-            if {[info exists override($widgets(attribute_name))]} {
+            if {[info exists override(${widgets(attribute_name)})]} {
                 append element_create_cmd " [dtype::form::value_switch \
                     -widget $widgets(widget) \
                     -value $override($widgets(attribute_name))]"