|
@@ -13,6 +13,7 @@ namespace Symfony\Component\Form;
|
|
|
|
|
|
use Symfony\Component\Form\Exception\FormException;
|
|
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
|
|
+use Symfony\Component\Form\Exception\CircularReferenceException;
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
|
@@ -110,6 +111,8 @@ class FormBuilder
|
|
|
*/
|
|
|
private $emptyData = '';
|
|
|
|
|
|
+ private $currentLoadingType;
|
|
|
+
|
|
|
/**
|
|
|
* Constructor.
|
|
|
*
|
|
@@ -538,6 +541,10 @@ class FormBuilder
|
|
|
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
|
|
|
}
|
|
|
|
|
|
+ if ($this->currentLoadingType && ($type instanceof FormTypeInterface ? $type->getName() : $type) == $this->currentLoadingType) {
|
|
|
+ throw new CircularReferenceException(is_string($type) ? $this->getFormFactory()->getType($type) : $type);
|
|
|
+ }
|
|
|
+
|
|
|
$this->children[$child] = array(
|
|
|
'type' => $type,
|
|
|
'options' => $options,
|
|
@@ -655,6 +662,11 @@ class FormBuilder
|
|
|
return $instance;
|
|
|
}
|
|
|
|
|
|
+ public function setCurrentLoadingType($type)
|
|
|
+ {
|
|
|
+ $this->currentLoadingType = $type;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the event dispatcher.
|
|
|
*
|