Index: branches/1.1dev/lib/TemplateGlue.inc.php
===================================================================
--- branches/1.1dev/lib/TemplateGlue.inc.php	(revision 265)
+++ branches/1.1dev/lib/TemplateGlue.inc.php	(revision 283)
@@ -118,8 +118,4 @@
 function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null)
 {	
-    ?>
-    <table>
-        <tr>
-    <?php
     // Sometimes preselected comes as a comma list.
     if (!is_array($preselected)) {
@@ -138,48 +134,54 @@
 	$values = getSetEnumFieldValues($db_table, $db_col);
 	
-    // Initialize the HTML table generation vars.
-    $num_cells = sizeof($values) - 1;
-    $num_rows = floor($num_cells / $columns);
-    $cols_lastrow = $num_cells % $columns;
-    $row_cnt = 0;
-    $col_cnt = 0;
-	foreach ($values as $item) {
-        if ($col_cnt == $columns) {
-            // Begin a new row.
-            ?></tr><tr><?php
-            $col_cnt = 0;
-            $row_cnt++;
-        }
-        if ($col_cnt < $cols_lastrow) {
-            $lastrow_add = $col_cnt;
-        } else {
-            $lastrow_add = $cols_lastrow;
-        }
-        $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
-        $col_cnt++;
-        
-        // Look for preselected value.
-        if (in_array($item, $preselected)) {
-            $checked = ' checked="checked"';
-        } else {
-            $checked = '';
-        }
-        if ('allone' == $flag) {
-            // Print a cell with multidimentioal array checkboxes.
-            ?><td><input type="checkbox" name="dbcol[<?php echo $db_col; ?>][<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
-            <?php
-         } else {
-            // Print a cell with basic named checkboxes.
-            ?><td><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
-            <?php
-        }
-    }
-    if ($col_cnt < $columns) {
-        // This last cell must expand to fill the last blank cells.
-        ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
-    }
-    ?>
-        </tr>
-    </table><?php
+    if (!empty($values)) {
+        ?>
+        <table>
+            <tr>
+        <?php
+        // Initialize the HTML table generation vars.
+        $num_cells = sizeof($values) - 1;
+        $num_rows = floor($num_cells / $columns);
+        $cols_lastrow = $num_cells % $columns;
+        $row_cnt = 0;
+        $col_cnt = 0;
+    	foreach ($values as $item) {
+            if ($col_cnt == $columns) {
+                // Begin a new row.
+                ?></tr><tr><?php
+                $col_cnt = 0;
+                $row_cnt++;
+            }
+            if ($col_cnt < $cols_lastrow) {
+                $lastrow_add = $col_cnt;
+            } else {
+                $lastrow_add = $cols_lastrow;
+            }
+            $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
+            $col_cnt++;
+        
+            // Look for preselected value.
+            if (in_array($item, $preselected)) {
+                $checked = ' checked="checked"';
+            } else {
+                $checked = '';
+            }
+            if ('allone' == $flag) {
+                // Print a cell with multidimentioal array checkboxes.
+                ?><td><label><input type="checkbox" name="dbcol[<?php echo $db_col; ?>][<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+                <?php
+             } else {
+                // Print a cell with basic named checkboxes.
+                ?><td><label><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+                <?php
+            }
+        }
+        if ($col_cnt < $columns) {
+            // This last cell must expand to fill the last blank cells.
+            ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
+        }
+        ?>
+            </tr>
+        </table><?php
+    }
 }
 
@@ -196,8 +198,4 @@
 function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null)
 {	
-    ?>
-    <table>
-        <tr>
-    <?php
     // Sometimes preselected comes as a comma list.
     if (!is_array($preselected)) {
@@ -216,42 +214,48 @@
 	$values = getSetEnumFieldValues($db_table, $db_col);
 	
-    // Initialize the HTML table generation vars.
-    $num_cells = sizeof($values) - 1;
-    $num_rows = floor($num_cells / $columns);
-    $cols_lastrow = $num_cells % $columns;
-    $row_cnt = 0;
-    $col_cnt = 0;
-	foreach ($values as $item) {
-        if ($col_cnt == $columns) {
-            // Begin a new row.
-            ?></tr><tr><?php
-            $col_cnt = 0;
-            $row_cnt++;
-        }
-        if ($col_cnt < $cols_lastrow) {
-            $lastrow_add = $col_cnt;
-        } else {
-            $lastrow_add = $cols_lastrow;
-        }
-        $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
-        $col_cnt++;
-        
-        // Look for preselected value.
-        if (in_array($item, $preselected)) {
-            $checked = ' checked="checked"';
-        } else {
-            $checked = '';
-        }
-        // Print a cell with basic named checkboxes.
-        ?><td><input type="radio" name="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
-        <?php
-    }
-    if ($col_cnt < $columns) {
-        // This last cell must expand to fill the last blank cells.
-        ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
-    }
-    ?>
-        </tr>
-    </table><?php
+    if (!empty($values)) {
+        ?>
+        <table>
+            <tr>
+        <?php
+        // Initialize the HTML table generation vars.
+        $num_cells = sizeof($values) - 1;
+        $num_rows = floor($num_cells / $columns);
+        $cols_lastrow = $num_cells % $columns;
+        $row_cnt = 0;
+        $col_cnt = 0;
+    	foreach ($values as $item) {
+            if ($col_cnt == $columns) {
+                // Begin a new row.
+                ?></tr><tr><?php
+                $col_cnt = 0;
+                $row_cnt++;
+            }
+            if ($col_cnt < $cols_lastrow) {
+                $lastrow_add = $col_cnt;
+            } else {
+                $lastrow_add = $cols_lastrow;
+            }
+            $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
+            $col_cnt++;
+        
+            // Look for preselected value.
+            if (in_array($item, $preselected)) {
+                $checked = ' checked="checked"';
+            } else {
+                $checked = '';
+            }
+            // Print a cell with basic named checkboxes.
+            ?><td><label><input type="radio" name="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
+            <?php
+        }
+        if ($col_cnt < $columns) {
+            // This last cell must expand to fill the last blank cells.
+            ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
+        }
+        ?>
+            </tr>
+        </table><?php
+    }
 }
 
@@ -388,5 +392,5 @@
         
         // Print a cell with basic named checkboxes.
-        ?><td><input type="checkbox" name="<?php echo $val_column; ?>[<?php echo $box[$val_column]; ?>]"<?php echo $checked; ?> /></td><td><?php echo oTxt($box[$key_column]); ?></td>
+        ?><td><input type="checkbox" id="<?php echo $val_column . '-' . $box[$val_column]; ?>" name="<?php echo $val_column; ?>[<?php echo $box[$val_column]; ?>]"<?php echo $checked; ?> /></td><td><label for="<?php echo $val_column . '-' . $box[$val_column]; ?>"><?php echo oTxt($box[$key_column]); ?></label></td>
         <?php
     }
