Skip to content

CollectionField handles the absence of normal input. #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ static protected function detectMetadataDriver($dir, ContainerBuilder $container
}
$container->addResource(new FileResource($resource));

if (count(glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.xml'))) {
if (($files = glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.xml')) && count($files)) {
return 'xml';
} elseif (count(glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.yml'))) {
} elseif (($files = glob($dir.'/Resources/config/doctrine/metadata/mongodb/*.yml')) && count($files)) {
return 'yml';
}

Expand Down
24 changes: 13 additions & 11 deletions src/Symfony/Component/Form/CollectionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,20 @@ protected function configure()

public function setData($collection)
{
if (!is_array($collection) && !$collection instanceof \Traversable) {
throw new UnexpectedTypeException('The data passed to the CollectionField must be an array or a Traversable');
}

foreach ($this as $name => $field) {
if (!$this->getOption('modifiable') || '$$key$$' != $name) {
$this->remove($name);
if (null !== $collection) {
if (!is_array($collection) && !$collection instanceof \Traversable) {
throw new UnexpectedTypeException('The data passed to the CollectionField must be an array or a Traversable');
}

foreach ($this as $name => $field) {
if (!$this->getOption('modifiable') || '$$key$$' != $name) {
$this->remove($name);
}
}

foreach ($collection as $name => $value) {
$this->add($this->newField($name, $name));
}
}

foreach ($collection as $name => $value) {
$this->add($this->newField($name, $name));
}

parent::setData($collection);
Expand Down