petkopara / petkoparamultisearchbundle Goto Github PK
View Code? Open in Web Editor NEWSymfony bundle for Multi Criteria Search in Doctrine entities using Form or Service.
Symfony bundle for Multi Criteria Search in Doctrine entities using Form or Service.
Postgres LIKE statement doesn't support numbers
Now the search is complex with word by word search.
Add support for simple one word or phrase search
I can't figure out how to install the master branch (because I don't understand aliases)
Neither of these work:
composer req petkopara/multi-search-bundle:^1.0.x-dev
composer req petkopara/multi-search-bundle:@1.0.x-dev
I've tried every variation I can think of, can you document the correct way? Thanks.
This doesn't work with the search form. I'm getting a toomanyparameters error (1 bound and you provide 2).
if(!($this->get('security.authorization_checker')->isGranted('ROLE_ADMIN'))){
$queryBuilder = $em->getRepository('AppBundle:EventosInstitucionales')
->createQueryBuilder('e')
->andWhere('e.user = :id')
->setParameter('id', $loggedInUserId)
; // this is not working.
}else{
$queryBuilder = $em->getRepository('AppBundle:EventosInstitucionales')
->createQueryBuilder('e'); // this works fine!
}
Any ideas how to solve this?
This is my filterType. By the way, here I don't have a field that is called "user" I added it after I create the searchType. This new field is a OneToMany relation with a my user table.
$builder->add('search', MultiSearchType::class, array(
'class' => 'AppBundle:EventosInstitucionales',
'search_fields' => array( //optional, if it's empty it will search in the all entity columns
'id',
'nombreInstitucion',
'direccionResponsablePrograma',
'nombrePrograma',
'nombreContactoResponsablePrograma',
'telefonoContactoResponsablePrograma',
'emailContactoResponsablePrograma',
'actividad',
'departamento',
'lugar',
'fecha',
'hora',
'minuto',
'poblacionObjetivo',
'numeroParticipantes',
'nombreContactoResponsableActividad',
'telefonoContactoResponsableActividad',
'emailContactoResponsableActividad'
),
));
$builder->setMethod('GET');
Ok, error arrise inside this method
protected function paginator($queryBuilder, Request $request)
{
//var_dump("PAGINATOR");die();
//sorting
$sortCol = $queryBuilder->getRootAlias().'.'.$request->get('pcg_sort_col', 'id');
$queryBuilder->orderBy($sortCol, $request->get('pcg_sort_order', 'desc'));
// Paginator
$adapter = new DoctrineORMAdapter($queryBuilder);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($request->get('pcg_show' , 10));
try {
$pagerfanta->setCurrentPage($request->get('pcg_page', 1));
} catch (\Pagerfanta\Exception\OutOfRangeCurrentPageException $ex) {
$pagerfanta->setCurrentPage(1);
}
//ERROR arrise here
$entities = $pagerfanta->getCurrentPageResults();
// Paginator - route generator
$me = $this;
$routeGenerator = function($page) use ($me, $request)
{
$requestParams = $request->query->all();
$requestParams['pcg_page'] = $page;
return $me->generateUrl('eventosinstitucionales', $requestParams);
};
// Paginator - view
$view = new TwitterBootstrap3View();
$pagerHtml = $view->render($pagerfanta, $routeGenerator, array(
'proximity' => 3,
'prev_message' => 'previous',
'next_message' => 'next',
));
return array($entities, $pagerHtml);
}
I'd like to use this bundle with Symfony 6. What do you think of a new release that supports the currently maintained versions of Symfony and the other dependencies (like Doctrine).
Some of the supported versions of Symfony are very old, I can make the changes to so it runs with Symfony 6, but it will break the unmaintained versions.
Add option to search in the relations.
Hello,
I have installed this search bundle. I created all the files which are necessary. But the example on the official documentation is not clear to me cause i am newbie to symfony.
here is my source code
Controller
namespace BlogBundle\Controller;
use BlogBundle\Entity\Article;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Description of SearchController
*
* @author admin
*/
class SearchController extends Controller {
public function indexAction(Request $request) {
$search = $request->get('search');
$em = $this->getDoctrine()->getManager();
$queryBuilder = $em->getRepository('BlogBundle:Post')->createQueryBuilder('e');
$filterForm = $this->createForm('BlogBundle\Form\SearchFormType');
// Bind values from the request
$filterForm->handleRequest($request);
if ($filterForm->isValid()) {
// Build the query from the given form object
$queryBuilder = $this->get('petkopara_multi_search.builder')->searchForm($queryBuilder, $filterForm->get('search'));
}
return $this->render('article/index.html.twig', array(
'filterForm' => $filterForm,
));
}
}
Form Type
namespace BlogBundle\Form;
use BlogBundle\Entity\Article;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class ArticleSearchType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('search', MultiSearchType::class, array(
'class' => 'BlogBundle:Article'
));
}
public function getName() {
return 'blog_article_search';
}
}
View
<div class="col-md-12" style="border-color:#0b90c4;border-style:solid;padding:25px;margin-bottom:25px;">
{#{{ render(controller('BlogBundle:Article:list')) }}#}
{{ form_start(filterForm) }}
{{ form_rest(filterForm) }}
{{ form_end(filterForm) }}
</div>
Did i miss anything else?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.