Skip to content

Commit

Permalink
Changed values of boolean fields in search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiagnoni committed Jun 27, 2012
1 parent b18b8d8 commit ebbcdde
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/LyraAdminExtension.php
Expand Up @@ -429,7 +429,7 @@ private function setFilterFieldsDefaults()
case 'choice':
$filters[$field]['options'] = array_merge(
$filters[$field]['options'], array(
'choices' => array(1 => 'Yes', 0 => 'No', null => 'Both'),
'choices' => array('on' => 'Yes', 'off' => 'No', null => 'Both'),
'expanded' => true
)
);
Expand Down
7 changes: 1 addition & 6 deletions Filter/Filter.php
Expand Up @@ -228,14 +228,9 @@ protected function removeEmptyCriteria($criteria)
$value = null;
}
break;
case 'boolean':
if ('' == $value) {
$value = null;
}
break;
}

if (null !== $value) {
if (!empty($value)) {
$filtered[$name] = $value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion QueryBuilder/QueryBuilder.php
Expand Up @@ -128,7 +128,7 @@ protected function addFilterCriteria($qb, $criteria)
break;
case 'boolean':
$qb->andWhere(
$qb->expr()->eq($alias.'.'.$field, $value)
$qb->expr()->eq($alias.'.'.$field, $value === 'on' ? 1 : 0)
);

break;
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Filter/dialog.html.twig
Expand Up @@ -18,7 +18,7 @@
{{ (date.from is empty ? 'filter.date.upto' : 'filter.date.to')|trans({}, 'LyraAdminBundle')}} {{ date.to|date('j/M/Y') }}
{% endif %}
{% elseif field.type == 'boolean' %}
{{ (criteria[field.name] ? 'show.boolean.true' : 'show.boolean.false')|trans({}, 'LyraAdminBundle') }}
{{ (criteria[field.name] == 'on' ? 'show.boolean.true' : 'show.boolean.false')|trans({}, 'LyraAdminBundle') }}
{% else %}
{{ criteria[field.name] }}
{% endif %}
Expand Down

0 comments on commit ebbcdde

Please sign in to comment.