use preferred_choices in favor of preferred_query
This commit is contained in:
parent
6855cffb1d
commit
05fca6d80e
@ -340,7 +340,11 @@ class ModelChoiceList extends ObjectChoiceList
|
|||||||
private function load()
|
private function load()
|
||||||
{
|
{
|
||||||
$models = (array) $this->query->find();
|
$models = (array) $this->query->find();
|
||||||
$preferred = (array) $this->preferredQuery->find();
|
|
||||||
|
$preferred = array();
|
||||||
|
if ($this->preferredQuery instanceof ModelCriteria) {
|
||||||
|
$preferred = (array) $this->preferredQuery->find();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// The second parameter $labels is ignored by ObjectChoiceList
|
// The second parameter $labels is ignored by ObjectChoiceList
|
||||||
|
@ -24,7 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
|||||||
* @author William Durand <william.durand1@gmail.com>
|
* @author William Durand <william.durand1@gmail.com>
|
||||||
* @author Toni Uebernickel <tuebernickel@gmail.com>
|
* @author Toni Uebernickel <tuebernickel@gmail.com>
|
||||||
*
|
*
|
||||||
* Example using the preferred_query option.
|
* Example using the preferred_choices option.
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* public function buildForm(FormBuilderInterface $builder, array $options)
|
* public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
@ -38,7 +38,7 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
|||||||
* ->orderByName()
|
* ->orderByName()
|
||||||
* ->endUse()
|
* ->endUse()
|
||||||
* ,
|
* ,
|
||||||
* 'preferred_query' => ProductQuery::create()
|
* 'preferred_choices' => ProductQuery::create()
|
||||||
* ->filterByIsTopProduct(true)
|
* ->filterByIsTopProduct(true)
|
||||||
* ,
|
* ,
|
||||||
* ))
|
* ))
|
||||||
@ -64,7 +64,7 @@ class ModelType extends AbstractType
|
|||||||
$options['choices'],
|
$options['choices'],
|
||||||
$options['query'],
|
$options['query'],
|
||||||
$options['group_by'],
|
$options['group_by'],
|
||||||
$options['preferred_query']
|
$options['preferred_choices']
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +79,6 @@ class ModelType extends AbstractType
|
|||||||
'choice_list' => $choiceList,
|
'choice_list' => $choiceList,
|
||||||
'group_by' => null,
|
'group_by' => null,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
'preferred_query' => null,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user