Fix regression: allow using custom methods. (#440)

We used to be able to use our own methods to generate the `$choiceLabel`, instead of just the columns of the object. Now, Propel complains about the column not existing in the object.
This commit is contained in:
Peter Potrowl 2017-01-09 12:28:54 +01:00 committed by Marc J. Schmidt
parent df24480a4f
commit c4359c39b6
1 changed files with 6 additions and 2 deletions

View File

@ -214,9 +214,13 @@ class ModelType extends AbstractType
$valueProperty = $options['property'];
/** @var ModelCriteria $query */
$query = $options['query'];
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
$choiceLabel = function($choice) use ($getter) {
$choiceLabel = function($choice) use ($valueProperty) {
$getter = 'get'.ucfirst($valueProperty);
if (!method_exists($choice, $getter)) {
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
}
return call_user_func([$choice, $getter]);
};
}