Skip to content

Commit

Permalink
allow extension filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMendolia committed Sep 23, 2023
1 parent d1f922d commit 4840f91
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/Form/BookFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,25 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
},
]);

$builder->add('extension', Type\ChoiceType::class, [
'choices' => [
'Any' => '',
'epub' => 'epub',
'cbr' => 'cbr',
'cbz' => 'cbz',
'pdf' => 'pdf',
],
'required' => false,
'mapped' => false,
'target_callback' => function (QueryBuilder $qb, ?string $readValue): void {

if ($readValue !== null) {
$qb->andWhere($qb->expr()->like('book.extension', ':extension'));
$qb->setParameter('extension', $readValue);
}
},
]);

$builder->add('favorite', Type\ChoiceType::class, [
'choices' => [
'Any' => '',
Expand Down
7 changes: 5 additions & 2 deletions templates/default/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@
{{ form_row(form.serieIndexLTE) }}
</div>

<div class="col-md-3">
<div class="col-md-2">
{{ form_row(form.extension) }}
</div>
<div class="col-md-2">
{{ form_row(form.publisher) }}
</div>
<div class="col-md-3">
<div class="col-md-2">
{{ form_row(form.orderBy) }}

</div>
Expand Down

0 comments on commit 4840f91

Please sign in to comment.