diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index 719a587348..ed94e2ca16 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -46,11 +46,7 @@ class FormFactory implements FormFactoryInterface // TESTME if (null === $name) { - $typeAsString = is_object($type) ? get_class($type) : $type; - - if (preg_match('/\w+$/', $typeAsString, $matches)) { - $name = $matches[0]; - } + $name = is_object($type) ? $type->getName() : $type; } while (null !== $type) { diff --git a/src/Symfony/Component/Form/Type/AbstractType.php b/src/Symfony/Component/Form/Type/AbstractType.php index 5cc93338c2..d806909cc5 100644 --- a/src/Symfony/Component/Form/Type/AbstractType.php +++ b/src/Symfony/Component/Form/Type/AbstractType.php @@ -47,6 +47,10 @@ abstract class AbstractType implements FormTypeInterface public function getName() { - return get_class($this); + if (preg_match('/\\\\([a-z]+)(?:Form|Type)$/im', get_class($this), $matches)) { + $name = strtolower($matches[1]); + } + + return $name; } -} \ No newline at end of file +}