fix to loadChoicesForValues()

This commit is contained in:
Jeffrey Wong 2016-06-10 16:35:54 -07:00 committed by Toni Uebernickel
parent 0b31960534
commit 1abe7fc673
No known key found for this signature in database
GPG key ID: BE780866F6035C7A
2 changed files with 4 additions and 4 deletions

View file

@ -109,7 +109,8 @@ class PropelChoiceLoader implements ChoiceLoaderInterface
// Optimize performance in case we have a single-field identifier
if (!$this->choiceList && $this->identifierAsIndex && current($this->identifier) instanceof ColumnMap) {
$phpName = current($this->identifier)->getPhpName();
$unorderedObjects = $this->query->filterBy($phpName, $values);
$query = clone $this->query;
$unorderedObjects = $query->filterBy($phpName, $values, \Criteria::IN)->find();
$objectsById = array();
$objects = array();
@ -203,7 +204,7 @@ class PropelChoiceLoader implements ChoiceLoaderInterface
if ($model instanceof \BaseObject) {
return array($model->getPrimaryKey());
}
return $model->getPrimaryKeys();
}

View file

@ -211,7 +211,6 @@ class ModelType extends AbstractType
$valueProperty = $options['property'];
/** @var ModelCriteria $query */
$query = $options['query'];
//var_dump($query->getTableMap());
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
$choiceLabel = function($choice) use ($getter) {
@ -240,7 +239,7 @@ class ModelType extends AbstractType
$resolver->setRequired(array('class'));
$resolver->setNormalizer('query', $queryNormalizer);
$resolver->setNormalizer('choice_label', $choiceLabelNormalizer);
$resolver->setAllowedTypes('query', ['null', 'Propel\Runtime\ActiveQuery\ModelCriteria']);
$resolver->setAllowedTypes('query', ['null', '\ModelCriteria']);
}
/**