[dev] FormSprocket question

Anil Madhavapeddy anil@recoil.org
Fri, 23 Aug 2002 17:22:58 +0100


When I try to add a comment with only a single group
defined (Any Group), the FormSprocket fails to recognise that
as a valid selection.  It accepts the input if there is more
than one group available through Horde.

It seems to be because FormSprocket::addVariable() optimises
the case where there is only one enum, but adds the value
into both the _vars and _variables array.

The below patch simply loses the optimisation and fixes the
problem for me - does it look ok?  Btw, this class would
really benefit from some docs, especially the extremely funky
looking _useTypes() and _useForms() functions :-)

Index: FormSprocket.php
===================================================================
RCS file: /repository/horde/lib/FormSprocket.php,v
retrieving revision 1.20
diff -u -r1.20 FormSprocket.php
--- FormSprocket.php    18 Aug 2002 21:04:15 -0000      1.20
+++ FormSprocket.php    23 Aug 2002 16:19:20 -0000
@@ -67,11 +67,6 @@
     {
         $var = new FormSprocket_Variable($humanName, $varName, $type,
                                          $required, $readonly, $description);
-        if ($var->getTypeName() == 'enum' &&
-            count($var->getValues()) == 1) {
-            $vals = array_keys($var->getValues());
-            $this->_vars->addVar($var->varName, $vals[0]);
-        }
         $idx = array_push($this->_variables, $var);
         return $this->_variables[$idx - 1];
     }