diff --git a/lib/Horde/Form.php b/lib/Horde/Form.php index d75812b..58c1441 100644 --- a/lib/Horde/Form.php +++ b/lib/Horde/Form.php @@ -202,14 +202,15 @@ public static function createVariable( ) { $arr = explode(':', $type, 2); if (count($arr) == 2) { - $app = $arr[0]; + $app = ucfirst($arr[0]); $name = $arr[1]; } else { $app = 'Horde'; $name = $arr[0]; } - $class = $app . '\\Form\\V3\\' . ucfirst($name) . 'Variable'; + $name = ucfirst($name); + $class = $app . '\\Form\\V3\\' . $name . 'Variable'; $modern = class_exists($class); if ($modern) { $var = new $class( @@ -221,11 +222,12 @@ public static function createVariable( ); } elseif (self::$legacy) { $class = $app . '_Form_Type_' . $name; - if (!class_exists($class)) { - throw new Horde_Exception(sprintf('Nonexistent class "%s" for field type "%s"', $class, $name)); - } - $var = new $class(); + $var = class_exists($class) ? new $class() : null; } else { + $var = null; + } + + if ($var === null) { throw new Horde_Exception(sprintf('Nonexistent class "%s" for field type "%s"', $class, $name)); } diff --git a/src/V3/BaseVariable.php b/src/V3/BaseVariable.php index a96511a..b87fbb5 100644 --- a/src/V3/BaseVariable.php +++ b/src/V3/BaseVariable.php @@ -344,7 +344,14 @@ public function getType() */ public function getTypeName(): string { - return mb_strtolower(str_replace('Horde\Form\V3\\', '', substr($this::class, 0, -8))); + $parts = explode('\\', $this::class); + $app = strtolower($parts[0]); + $name = strtolower(substr($parts[count($parts) - 1], 0, -8)); + if ($app !== 'horde') { + // legacy + $name = $app . '_form_type_' . $name; + } + return $name; } /**