public __construct ( Symfony\Component\Form\FormFactoryInterface $factory, $type, array $options = [], $allowAdd = false, $allowDelete = false ) | ||
$factory | Symfony\Component\Form\FormFactoryInterface | |
$options | array |
public function __construct(FormFactoryInterface $factory, array $prototypes, array $options = array(), $allowAdd = false, $allowDelete = false) { $this->factory = $factory; foreach ($prototypes as $prototype) { $dataClass = $prototype->getConfig()->getDataClass(); $type = $prototype->getConfig()->getType(); $typeKey = $type instanceof ResolvedFormTypeInterface ? $type->getName() : $type; $this->typeMap[$typeKey] = $type; $this->classMap[$dataClass] = $type; } $defaultType = reset($prototypes)->getConfig()->getType()->getName(); parent::__construct($defaultType, $options, $allowAdd, $allowDelete); }
/** * @param array $prototypes * @param array $options * @param bool $allowAdd * @param bool $allowDelete * @param bool $deleteEmpty * @throws \InvalidArgumentException */ public function __construct(array $prototypes, array $options = array(), $allowAdd = false, $allowDelete = false, $deleteEmpty = false) { foreach ($prototypes as $prototype) { /** @var FormInterface $prototype */ $dataClass = $prototype->getConfig()->getOption('data_class'); if (is_null($dataClass)) { throw new \InvalidArgumentException("Only form types with data_class are supported!"); } $type = $prototype->getConfig()->getType()->getInnerType(); $key = $type instanceof FormTypeInterface ? $type->getName() : $type; $this->typeMap[$key] = $type; $this->classMap[$dataClass] = $type; } parent::__construct(null, $options, $allowAdd, $allowDelete); }
/** * @param array<FormInterface> $prototypes * @param array $options * @param bool $allowAdd * @param bool $allowDelete * @param string $typeFieldName * @param string $indexProperty */ public function __construct(array $prototypes, array $options = array(), $allowAdd = false, $allowDelete = false, $typeFieldName = '_type', $indexProperty = null) { $this->typeFieldName = $typeFieldName; $this->indexProperty = $indexProperty; $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); $defaultType = null; foreach ($prototypes as $prototype) { /** @var FormInterface $prototype */ $modelClass = $prototype->getConfig()->getOption('model_class'); $type = $prototype->getConfig()->getType()->getInnerType(); if (null === $defaultType) { $defaultType = $type; } $typeKey = $type instanceof FormTypeInterface ? $type->getName() : $type; $this->typeMap[$typeKey] = $type; $this->classMap[$modelClass] = $type; } parent::__construct($defaultType, $options, $allowAdd, $allowDelete); }