Skip to content

Commit

Permalink
Simple MultiSelect Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault CORDIER committed Oct 22, 2013
1 parent 65a28b9 commit 1b2ccb8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Event/Subscriber/DoctrineSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ public function filterValue(ApplyFilterEvent $event)
if ('' !== $values['value'] && null !== $values['value']) {
// alias.field -> alias_field
$fieldName = str_replace('.', '_', $event->getField());

$qb->andWhere($expr->eq($event->getField(), ':' . $fieldName))
->setParameter($fieldName, $values['value']);
if(is_array($values['value']) && sizeof($values['value']) > 0) {
$qb->andWhere($expr->in($event->getField(), $values['value']));
} elseif(is_array($values['value']) && sizeof($values['value']) == 0) {
// Multiselect is Empty - Don't Filter
} else {
$qb->andWhere($expr->eq($event->getField(), ':' . $fieldName))
->setParameter($fieldName, $values['value']);
}
}
}

Expand Down

0 comments on commit 1b2ccb8

Please sign in to comment.