Add search bar to filter data within entity type fields in symfony6
P粉078945182
P粉078945182 2024-04-03 21:32:53
0
1
313

I have a problem, I want to filter the output data in this entity type I found a solution but I should change the value of searchterm inside the script,

$searchTerm = 'ri';

$builder->add('userInput', EntityType::class, [
                'class' => User::class,
                'query_builder' => function(EntityRepository $er) use ($searchTerm) {
                    return $er->createQueryBuilder('u')
                        ->where('u.username LIKE :searchTerm')
                        ->setParameter('searchTerm', '%'.$searchTerm.'%')
                        ->orderBy('u.username', 'ASC');
                },
                'choice_label' => 'username',
                'required' => false,
            ])

I want to add bar search to this entityType to filter the data of u.username

P粉078945182
P粉078945182

reply all(1)
P粉348915572

I found the solution, just implement Select2 in JS.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!