From 9dfbde6730548d50d51d49d3e31ebc316ce516c9 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 23 Apr 2017 16:29:41 +0200 Subject: [PATCH 1/2] Title filter in account page --- src/Gist/Form/FilterGistForm.php | 12 ++++++++++++ src/Gist/Resources/views/My/my.html.twig | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Gist/Form/FilterGistForm.php b/src/Gist/Form/FilterGistForm.php index d1dcac8..3cfee91 100644 --- a/src/Gist/Form/FilterGistForm.php +++ b/src/Gist/Form/FilterGistForm.php @@ -44,6 +44,18 @@ class FilterGistForm extends AbstractForm ) ); + $this->builder->add( + 'title', + 'text', + array( + 'required' => false, + 'attr' => array( + 'placeholder' => $this->translator->trans('form.title.placeholder'), + 'class' => 'form-control', + ) + ) + ); + $this->builder->setMethod('GET'); return $this->builder; diff --git a/src/Gist/Resources/views/My/my.html.twig b/src/Gist/Resources/views/My/my.html.twig index bf3f44c..fdd2933 100644 --- a/src/Gist/Resources/views/My/my.html.twig +++ b/src/Gist/Resources/views/My/my.html.twig @@ -45,7 +45,10 @@ {% set params = app.request.attributes.get('_route_params')|merge({page: 1}) %} -
+ +
+ {{ form_widget(filterForm.title) }} +
From 36f4fb98ff8b81952a9c592102a22bde2c9a5bb4 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 23 Apr 2017 16:30:26 +0200 Subject: [PATCH 2/2] Title filter in account page --- src/Gist/Model/User.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Gist/Model/User.php b/src/Gist/Model/User.php index e8c7629..e5d483b 100644 --- a/src/Gist/Model/User.php +++ b/src/Gist/Model/User.php @@ -64,6 +64,10 @@ class User extends BaseUser implements UserInterface $query->filterByType($options['type']); } + if (!empty($options['title'])) { + $query->filterByTitle('%'.$options['title'].'%', Criteria::LIKE); + } + if (!empty($options['cipher']) && $options['cipher'] !== 'anyway') { $bools = array( 'yes' => true,