From c4359c39b67009024e36bc4ea3543e47d70f0fad Mon Sep 17 00:00:00 2001 From: Peter Potrowl Date: Mon, 9 Jan 2017 12:28:54 +0100 Subject: [PATCH] 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. --- Form/Type/ModelType.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Form/Type/ModelType.php b/Form/Type/ModelType.php index fc681ee..c1c6954 100644 --- a/Form/Type/ModelType.php +++ b/Form/Type/ModelType.php @@ -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]); }; }