Allow specifying an application scope for custom form types.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 21:49:26 +0000 (16:49 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 21:53:33 +0000 (16:53 -0500)
This allows applications to add their own Horde_Form_Type_* classes
and have them be properly autoloaded. This is an interim solution only
until Horde_Form is refactored after 4.0 is released..

framework/Form/Form.php

index acab291..ab7ae6b 100644 (file)
@@ -155,7 +155,12 @@ class Horde_Form {
      */
     function getType($type, $params = array())
     {
-        $type_class = 'Horde_Form_Type_' . $type;
+        if (strpos($type, ':') !== false) {
+            list($app, $type) = explode(':', $type);
+            $type_class = $app . '_Form_Type_' . $type;
+        } else {
+            $type_class = 'Horde_Form_Type_' . $type;
+        }
         if (!class_exists($type_class)) {
             throw new Horde_Exception(sprintf('Nonexistant class "%s" for field type "%s"', $type_class, $type));
         }