Last active
March 10, 2016 06:31
-
-
Save symball/88de2e42e435e93d8201 to your computer and use it in GitHub Desktop.
Sonata Admin DataGrid filter trying to use foreign text index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | |
{ | |
/* Get the filtered tags */ | |
$repo = $this->getConfigurationPool()->getContainer()->get('repository.tag'); | |
$temp = $repo->findByType('job-role---buy-side'); | |
/* Work the results in to a choice compatible array */ | |
$choices = array(); | |
foreach ($temp as $entry) { $choices[$entry->getTitle()] = $entry->getTitle(); } | |
$datagridMapper | |
->add('buySideResponsibility', 'doctrine_mongo_callback', array( | |
'callback' => function($queryBuilder, $alias, $field, $value) { | |
if(!$value['value']) { | |
return true; | |
} | |
$queryBuilder | |
/* This is the referenceOne property that I would like to perform the text search on */ | |
->field('buySideResponsibility') | |
->text('"'.$value['value'].'"'); | |
return true; | |
}, 'field_type' => 'choice', 'field_options' => array( | |
'choices' => $choices | |
))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment