r2292 don't display optional attributes portlet if none exist. closes ticket 87
authorAaron Dummer <aaron@dummer.info>
Thu, 13 Nov 2008 23:54:16 +0000 (23:54 +0000)
committerAaron Dummer <aaron@dummer.info>
Thu, 13 Nov 2008 23:54:16 +0000 (23:54 +0000)
ChangeLog
inc/interface.php

index 95ea3df..fe01a9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,7 +6,7 @@
        update: allow port type to be changed if it isn't linked.  closes ticket 137 (by Aaron)
        update: add network security chapter and dictionary entries.  closes ticket 148 (by Aaron)
        update: add HP and Juniper dictionary entries.  closes tickets 145 and 165 (by Aaron)
-       update: combined two forms on object properties page into one.  closes ticket 36 (by Aaron)
+       update: combined two forms on object properties page into one.  closes tickets 36 and 87 (by Aaron)
        bugfix: show error message if snmp module isn't loaded.  closes ticket 43 (by Aaron)
 0.16.4 2008-11-04
        bugfix: display VS/RS config block in RS pool view
index 50cdf1d..f848957 100644 (file)
@@ -492,42 +492,46 @@ function renderEditObjectForm ($object_id)
        
        // optional attributes
        $values = getAttrValues ($object_id);
-       echo "<table border=0 cellspacing=0 cellpadding=5 align=center class=widetable>\n";
-       echo "<tr><th colspan=3><h2>Optional attributes</h2></th></tr>";
-       echo "<tr><th>&nbsp;</th><th>Attribute</th><th>Value</th></tr>\n";
-       echo '<input type=hidden name=num_attrs value=' . count($values) . ">\n";
-       $i = 0;
-       foreach ($values as $record)
-       {
-               echo "<input type=hidden name=${i}_attr_id value=${record['id']}>";
-               echo '<tr><td>';
-               if (!empty ($record['value']))
-               {
-                       echo "<a href='${root}process.php?page=${pageno}&tab=${tabno}&op=clearSticker&object_id=${object_id}&attr_id=${record['id']}'>";
-                       printImageHREF ('clear', 'Clear value');
-                       echo '</a>';
-               }
-               else
-                       echo '&nbsp;';
-               echo '</td>';
-               echo "<td class=tdright>${record['name']}:</td><td class=tdleft>";
-               switch ($record['type'])
+       if (count($values) > 0)
+       {
+               echo "<table border=0 cellspacing=0 cellpadding=5 align=center class=widetable>\n";
+               echo "<tr><th colspan=3><h2>Optional attributes</h2></th></tr>";
+               echo "<tr><th>&nbsp;</th><th>Attribute</th><th>Value</th></tr>\n";
+               echo '<input type=hidden name=num_attrs value=' . count($values) . ">\n";
+               $i = 0;
+               foreach ($values as $record)
                {
-                       case 'uint':
-                       case 'float':
-                       case 'string':
-                               echo "<input type=text name=${i}_value value='${record['value']}'>";
-                               break;
-                       case 'dict':
-                               $chapter = readChapter ($record['chapter_name']);
-                               $chapter[0] = '-- NOT SET --';
-                               printSelect ($chapter, "${i}_value", $record['key']);
-                               break;
+                       echo "<input type=hidden name=${i}_attr_id value=${record['id']}>";
+                       echo '<tr><td>';
+                       if (!empty ($record['value']))
+                       {
+                               echo "<a href='${root}process.php?page=${pageno}&tab=${tabno}&op=clearSticker&object_id=${object_id}&attr_id=${record['id']}'>";
+                               printImageHREF ('clear', 'Clear value');
+                               echo '</a>';
+                       }
+                       else
+                               echo '&nbsp;';
+                       echo '</td>';
+                       echo "<td class=tdright>${record['name']}:</td><td class=tdleft>";
+                       switch ($record['type'])
+                       {
+                               case 'uint':
+                               case 'float':
+                               case 'string':
+                                       echo "<input type=text name=${i}_value value='${record['value']}'>";
+                                       break;
+                               case 'dict':
+                                       $chapter = readChapter ($record['chapter_name']);
+                                       $chapter[0] = '-- NOT SET --';
+                                       printSelect ($chapter, "${i}_value", $record['key']);
+                                       break;
+                       }
+                       echo "</td></tr>\n";
+                       $i++;
                }
-               echo "</td></tr>\n";
-               $i++;
+               echo "</table>";
        }
-       echo "</table></td></tr>\n";
+       echo "</td></tr>\n";
 
        echo "<tr><th class=submit colspan=2>";
        printImageHREF ('SAVE', 'Save changes', TRUE);