Merge pull request #431 from peter17/3.0
Fix error on Form/Type/ModelType.php.
This commit is contained in:
commit
c605b9346f
|
@ -91,7 +91,7 @@ class ModelType extends AbstractType
|
||||||
{
|
{
|
||||||
return (string) $choice;
|
return (string) $choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the field name for a choice.
|
* Creates the field name for a choice.
|
||||||
*
|
*
|
||||||
|
@ -134,17 +134,17 @@ class ModelType extends AbstractType
|
||||||
$choiceLoader = function (Options $options) {
|
$choiceLoader = function (Options $options) {
|
||||||
// Unless the choices are given explicitly, load them on demand
|
// Unless the choices are given explicitly, load them on demand
|
||||||
if (null === $options['choices']) {
|
if (null === $options['choices']) {
|
||||||
|
|
||||||
$propelChoiceLoader = new PropelChoiceLoader(
|
$propelChoiceLoader = new PropelChoiceLoader(
|
||||||
$this->choiceListFactory,
|
$this->choiceListFactory,
|
||||||
$options['class'],
|
$options['class'],
|
||||||
$options['query'],
|
$options['query'],
|
||||||
$options['index_property']
|
$options['index_property']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $propelChoiceLoader;
|
return $propelChoiceLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,12 +178,15 @@ class ModelType extends AbstractType
|
||||||
$firstIdentifier = current($identifier);
|
$firstIdentifier = current($identifier);
|
||||||
if (count($identifier) === 1 && in_array($firstIdentifier->getPdoType(), [\PDO::PARAM_BOOL, \PDO::PARAM_INT, \PDO::PARAM_STR])) {
|
if (count($identifier) === 1 && in_array($firstIdentifier->getPdoType(), [\PDO::PARAM_BOOL, \PDO::PARAM_INT, \PDO::PARAM_STR])) {
|
||||||
return function($object) use ($firstIdentifier) {
|
return function($object) use ($firstIdentifier) {
|
||||||
return call_user_func([$object, 'get' . ucfirst($firstIdentifier->getPhpName())]);
|
if ($object) {
|
||||||
|
return call_user_func([$object, 'get' . ucfirst($firstIdentifier->getPhpName())]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
$queryNormalizer = function (Options $options, $query) {
|
$queryNormalizer = function (Options $options, $query) {
|
||||||
if ($query === null) {
|
if ($query === null) {
|
||||||
$queryClass = $options['class'] . 'Query';
|
$queryClass = $options['class'] . 'Query';
|
||||||
|
@ -202,7 +205,7 @@ class ModelType extends AbstractType
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
};
|
};
|
||||||
|
|
||||||
$choiceLabelNormalizer = function (Options $options, $choiceLabel) {
|
$choiceLabelNormalizer = function (Options $options, $choiceLabel) {
|
||||||
if ($choiceLabel === null) {
|
if ($choiceLabel === null) {
|
||||||
if ($options['property'] == null) {
|
if ($options['property'] == null) {
|
||||||
|
@ -212,16 +215,16 @@ class ModelType extends AbstractType
|
||||||
/** @var ModelCriteria $query */
|
/** @var ModelCriteria $query */
|
||||||
$query = $options['query'];
|
$query = $options['query'];
|
||||||
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
|
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
|
||||||
|
|
||||||
$choiceLabel = function($choice) use ($getter) {
|
$choiceLabel = function($choice) use ($getter) {
|
||||||
return call_user_func([$choice, $getter]);
|
return call_user_func([$choice, $getter]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $choiceLabel;
|
return $choiceLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'query' => null,
|
'query' => null,
|
||||||
'index_property' => null,
|
'index_property' => null,
|
||||||
|
|
Loading…
Reference in a new issue