Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Fix ModelType.php for Symfony-2.8 #1

Closed
wants to merge 2 commits into from

Conversation

pyguerder
Copy link

Using null will raise following exception: Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given, called in .../vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php on line 266 and defined

Using null will raise following exception: Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Extension\Core\Type\ChoiceType::normalizeLegacyChoices() must be of the type array, null given, called in .../vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php on line 266 and defined
As a consequence of fix fafca72, $choices is not loaded. With this test, it is.
@piogrek
Copy link

piogrek commented Dec 2, 2015

I guess the simplest way would be to do similar thing as in EntityType for doctrine - to make choices_as_values default 'true' according to a comment in symfony/symfony#16796

@@ -105,7 +105,7 @@ public function __construct($class, $labelPath = null, $choices = null, $queryOb
$this->identifier = $this->query->getTableMap()->getPrimaryKeys();
}

$this->loaded = is_array($choices) || $choices instanceof \Traversable;
$this->loaded = (is_array($choices) && array() !== $choices) || $choices instanceof \Traversable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. If the user passes an empty array explicitly, it must be used as the loaded choices

@pyguerder
Copy link
Author

I think this has been solved by the choice list normalizer and can be closed. See symfony/symfony/pull/17163

@pyguerder pyguerder closed this Jan 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants