Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $builder->add('name', EntityType::class, [
- 'class' => Region::class,
- 'choice_label' => 'name_with_type',
- 'query_builder' => function (EntityRepository $er) {
- return $er->createQueryBuilder('u')
- ->orderBy('u.name_with_type', 'ASC');
- },
- 'multiple' => true,
- 'expanded' => true,
- ])
- // 'choice_name' => function ($entity) {
- // return $entity->getNameWithType();
- // },
- ->add('save', SubmitType::class, array('label' => 'Найти'))
- ;
- // Это генерит
- <input type="checkbox" id="region_form_name_46" name="region_form[name][]" value="46">
- // Вылавливаю массив отмеченных чекбоксов
- $query = $request->query->get("region_form");
- $clinics = $clinicRepository->findByRegionField($query);
- // Репозиторий
- public function findByRegionField($value)
- {
- return $this->createQueryBuilder('c')
- ->andWhere('c.region IN (:val)')
- ->setParameter('val', $value)
- ->orderBy('c.id', 'ASC')
- ->setMaxResults(10)
- ->getQuery()
- ->getResult()
- ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement