diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index f5c14306aa..0a3eab0903 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -340,7 +340,11 @@ class ModelChoiceList extends ObjectChoiceList private function load() { $models = (array) $this->query->find(); - $preferred = (array) $this->preferredQuery->find(); + + $preferred = array(); + if ($this->preferredQuery instanceof ModelCriteria) { + $preferred = (array) $this->preferredQuery->find(); + } try { // The second parameter $labels is ignored by ObjectChoiceList diff --git a/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php b/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php index 14297e1889..faf5f25f1c 100644 --- a/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php +++ b/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php @@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; * @author William Durand * @author Toni Uebernickel * - * Example using the preferred_query option. + * Example using the preferred_choices option. * * * public function buildForm(FormBuilderInterface $builder, array $options) @@ -38,7 +38,7 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; * ->orderByName() * ->endUse() * , - * 'preferred_query' => ProductQuery::create() + * 'preferred_choices' => ProductQuery::create() * ->filterByIsTopProduct(true) * , * )) @@ -64,7 +64,7 @@ class ModelType extends AbstractType $options['choices'], $options['query'], $options['group_by'], - $options['preferred_query'] + $options['preferred_choices'] ); }; @@ -79,7 +79,6 @@ class ModelType extends AbstractType 'choice_list' => $choiceList, 'group_by' => null, 'by_reference' => false, - 'preferred_query' => null, )); }