Skip to content

Commit

Permalink
Fixes error
Browse files Browse the repository at this point in the history
  • Loading branch information
gmanen committed Jan 31, 2014
1 parent f1d2d55 commit 857bc6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Form/ItemParameterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function __construct(EntityManager $entityManager)
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityManager = $this->entityManager;

$builder
->add('parameter', 'text', array(
'read_only' => true,
Expand All @@ -43,7 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('type', 'hidden')
->add('labelField', 'hidden')
->add('valueField', 'hidden')
->addEventListener(FormEvents::POST_SET_DATA, function(FormEvent $event) {
->addEventListener(FormEvents::POST_SET_DATA, function(FormEvent $event) use ($entityManager) {
$form = $event->getForm();
$data = $event->getData();

Expand All @@ -54,7 +56,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
if ($data->getType()) {
if ($property = $data->getLabelField()) {
$valueField = $data->getValueField();
$results = $this->entityManager->getRepository($data->getType())->createQueryBuilder('v')
$results = $entityManager->getRepository($data->getType())->createQueryBuilder('v')
->select(sprintf('v.%s, v.%s',$valueField , $property))
->orderBy(sprintf('v.%s', $property), 'ASC')
->getQuery()->getArrayResult();
Expand Down

0 comments on commit 857bc6b

Please sign in to comment.