Changeset 283 for branches/1.1dev/lib


Ignore:
Timestamp:
Oct 20, 2007 5:58:31 PM (17 years ago)
Author:
quinn
Message:

Added <label> tags to TemplateGlue? forms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1dev/lib/TemplateGlue.inc.php

    r1 r283  
    118118function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null)
    119119{   
    120     ?>
    121     <table>
    122         <tr>
    123     <?php
    124120    // Sometimes preselected comes as a comma list.
    125121    if (!is_array($preselected)) {
     
    138134    $values = getSetEnumFieldValues($db_table, $db_col);
    139135   
    140     // Initialize the HTML table generation vars.
    141     $num_cells = sizeof($values) - 1;
    142     $num_rows = floor($num_cells / $columns);
    143     $cols_lastrow = $num_cells % $columns;
    144     $row_cnt = 0;
    145     $col_cnt = 0;
    146     foreach ($values as $item) {
    147         if ($col_cnt == $columns) {
    148             // Begin a new row.
    149             ?></tr><tr><?php
    150             $col_cnt = 0;
    151             $row_cnt++;
    152         }
    153         if ($col_cnt < $cols_lastrow) {
    154             $lastrow_add = $col_cnt;
    155         } else {
    156             $lastrow_add = $cols_lastrow;
    157         }
    158         $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
    159         $col_cnt++;
    160        
    161         // Look for preselected value.
    162         if (in_array($item, $preselected)) {
    163             $checked = ' checked="checked"';
    164         } else {
    165             $checked = '';
    166         }
    167         if ('allone' == $flag) {
    168             // Print a cell with multidimentioal array checkboxes.
    169             ?><td><input type="checkbox" name="dbcol[<?php echo $db_col; ?>][<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
    170             <?php
    171          } else {
    172             // Print a cell with basic named checkboxes.
    173             ?><td><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
    174             <?php
    175         }
    176     }
    177     if ($col_cnt < $columns) {
    178         // This last cell must expand to fill the last blank cells.
    179         ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
    180     }
    181     ?>
    182         </tr>
    183     </table><?php
     136    if (!empty($values)) {
     137        ?>
     138        <table>
     139            <tr>
     140        <?php
     141        // Initialize the HTML table generation vars.
     142        $num_cells = sizeof($values) - 1;
     143        $num_rows = floor($num_cells / $columns);
     144        $cols_lastrow = $num_cells % $columns;
     145        $row_cnt = 0;
     146        $col_cnt = 0;
     147        foreach ($values as $item) {
     148            if ($col_cnt == $columns) {
     149                // Begin a new row.
     150                ?></tr><tr><?php
     151                $col_cnt = 0;
     152                $row_cnt++;
     153            }
     154            if ($col_cnt < $cols_lastrow) {
     155                $lastrow_add = $col_cnt;
     156            } else {
     157                $lastrow_add = $cols_lastrow;
     158            }
     159            $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
     160            $col_cnt++;
     161       
     162            // Look for preselected value.
     163            if (in_array($item, $preselected)) {
     164                $checked = ' checked="checked"';
     165            } else {
     166                $checked = '';
     167            }
     168            if ('allone' == $flag) {
     169                // Print a cell with multidimentioal array checkboxes.
     170                ?><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>
     171                <?php
     172             } else {
     173                // Print a cell with basic named checkboxes.
     174                ?><td><label><input type="checkbox" name="<?php echo $db_col; ?>[<?php echo $item; ?>]"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?></label>&nbsp;</td>
     175                <?php
     176            }
     177        }
     178        if ($col_cnt < $columns) {
     179            // This last cell must expand to fill the last blank cells.
     180            ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
     181        }
     182        ?>
     183            </tr>
     184        </table><?php
     185    }
    184186}
    185187
     
    196198function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null)
    197199{   
    198     ?>
    199     <table>
    200         <tr>
    201     <?php
    202200    // Sometimes preselected comes as a comma list.
    203201    if (!is_array($preselected)) {
     
    216214    $values = getSetEnumFieldValues($db_table, $db_col);
    217215   
    218     // Initialize the HTML table generation vars.
    219     $num_cells = sizeof($values) - 1;
    220     $num_rows = floor($num_cells / $columns);
    221     $cols_lastrow = $num_cells % $columns;
    222     $row_cnt = 0;
    223     $col_cnt = 0;
    224     foreach ($values as $item) {
    225         if ($col_cnt == $columns) {
    226             // Begin a new row.
    227             ?></tr><tr><?php
    228             $col_cnt = 0;
    229             $row_cnt++;
    230         }
    231         if ($col_cnt < $cols_lastrow) {
    232             $lastrow_add = $col_cnt;
    233         } else {
    234             $lastrow_add = $cols_lastrow;
    235         }
    236         $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
    237         $col_cnt++;
    238        
    239         // Look for preselected value.
    240         if (in_array($item, $preselected)) {
    241             $checked = ' checked="checked"';
    242         } else {
    243             $checked = '';
    244         }
    245         // Print a cell with basic named checkboxes.
    246         ?><td><input type="radio" name="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> />&nbsp;<?php echo oTxt($item); ?>&nbsp;</td>
    247         <?php
    248     }
    249     if ($col_cnt < $columns) {
    250         // This last cell must expand to fill the last blank cells.
    251         ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
    252     }
    253     ?>
    254         </tr>
    255     </table><?php
     216    if (!empty($values)) {
     217        ?>
     218        <table>
     219            <tr>
     220        <?php
     221        // Initialize the HTML table generation vars.
     222        $num_cells = sizeof($values) - 1;
     223        $num_rows = floor($num_cells / $columns);
     224        $cols_lastrow = $num_cells % $columns;
     225        $row_cnt = 0;
     226        $col_cnt = 0;
     227        foreach ($values as $item) {
     228            if ($col_cnt == $columns) {
     229                // Begin a new row.
     230                ?></tr><tr><?php
     231                $col_cnt = 0;
     232                $row_cnt++;
     233            }
     234            if ($col_cnt < $cols_lastrow) {
     235                $lastrow_add = $col_cnt;
     236            } else {
     237                $lastrow_add = $cols_lastrow;
     238            }
     239            $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
     240            $col_cnt++;
     241       
     242            // Look for preselected value.
     243            if (in_array($item, $preselected)) {
     244                $checked = ' checked="checked"';
     245            } else {
     246                $checked = '';
     247            }
     248            // Print a cell with basic named checkboxes.
     249            ?><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>
     250            <?php
     251        }
     252        if ($col_cnt < $columns) {
     253            // This last cell must expand to fill the last blank cells.
     254            ?><td colspan="<?php echo $columns - $col_cnt; ?>">&nbsp;</td><?php
     255        }
     256        ?>
     257            </tr>
     258        </table><?php
     259    }
    256260}
    257261
     
    388392       
    389393        // Print a cell with basic named checkboxes.
    390         ?><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>
     394        ?><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>
    391395        <?php
    392396    }
Note: See TracChangeset for help on using the changeset viewer.