|
@@ -91,6 +91,8 @@ class FormFactory implements FormFactoryInterface
|
|
|
{
|
|
|
$this->loadTypeExtensions($type);
|
|
|
|
|
|
+ $this->validateFormTypeName($type);
|
|
|
+
|
|
|
$this->types[$type->getName()] = $type;
|
|
|
}
|
|
|
|
|
@@ -377,6 +379,8 @@ class FormFactory implements FormFactoryInterface
|
|
|
|
|
|
$this->loadTypeExtensions($type);
|
|
|
|
|
|
+ $this->validateFormTypeName($type);
|
|
|
+
|
|
|
$this->types[$name] = $type;
|
|
|
}
|
|
|
|
|
@@ -398,4 +402,11 @@ class FormFactory implements FormFactoryInterface
|
|
|
|
|
|
$type->setExtensions($typeExtensions);
|
|
|
}
|
|
|
+
|
|
|
+ private function validateFormTypeName(FormTypeInterface $type)
|
|
|
+ {
|
|
|
+ if (!preg_match('/^[a-z0-9_]+$/i', $type->getName())) {
|
|
|
+ throw new FormException(sprintf('The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".', get_class($type), $type->getName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|