|
@@ -3,8 +3,13 @@
|
|
namespace App\Form;
|
|
namespace App\Form;
|
|
|
|
|
|
use App\Dto\FiltersDTO;
|
|
use App\Dto\FiltersDTO;
|
|
|
|
+use App\Entity\User;
|
|
|
|
+use App\Repository\UserRepository;
|
|
|
|
+use Doctrine\ORM\QueryBuilder;
|
|
|
|
+use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
|
|
+use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
|
|
|
|
@@ -13,6 +18,20 @@ class FiltersType extends AbstractType
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
{
|
|
$builder
|
|
$builder
|
|
|
|
+ ->add('note', NumberType::class, [
|
|
|
|
+ 'required' => false,
|
|
|
|
+ 'label' => "Note au dessus de",
|
|
|
|
+ 'attr' => [
|
|
|
|
+ 'min' => 0,
|
|
|
|
+ 'max' => 5,
|
|
|
|
+ 'class' => "rating",
|
|
|
|
+ 'data-step' => 1,
|
|
|
|
+ 'data-show-clear' => "true",
|
|
|
|
+ 'data-show-caption' => "false",
|
|
|
|
+ 'data-size' => "sm",
|
|
|
|
+ 'data-theme' => "krajee-fa"
|
|
|
|
+ ],
|
|
|
|
+ ])
|
|
->add('nbResults', ChoiceType::class, [
|
|
->add('nbResults', ChoiceType::class, [
|
|
'choices' => [
|
|
'choices' => [
|
|
'10' => 10,
|
|
'10' => 10,
|
|
@@ -21,8 +40,17 @@ class FiltersType extends AbstractType
|
|
'100' => 100
|
|
'100' => 100
|
|
]
|
|
]
|
|
])
|
|
])
|
|
- ->add('userName', null, [
|
|
|
|
- 'required' => false
|
|
|
|
|
|
+ ->add('userName', EntityType::class, [
|
|
|
|
+ 'required' => false,
|
|
|
|
+ 'class' => User::class,
|
|
|
|
+ 'choice_label' => 'username',
|
|
|
|
+ 'choice_value' => function(?User $user): string {
|
|
|
|
+ return $user ? $user->getUserIdentifier() : '';
|
|
|
|
+ },
|
|
|
|
+ 'query_builder' => function (UserRepository $er): QueryBuilder {
|
|
|
|
+ return $er->createQueryBuilder('u')
|
|
|
|
+ ->orderBy('u.username', 'ASC');
|
|
|
|
+ }
|
|
])
|
|
])
|
|
->add('sortBy', ChoiceType::class, [
|
|
->add('sortBy', ChoiceType::class, [
|
|
'choices' => [
|
|
'choices' => [
|