GithubHelp home page GithubHelp logo

petkopara / petkoparamultisearchbundle Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 4.0 88 KB

Symfony bundle for Multi Criteria Search in Doctrine entities using Form or Service.

PHP 99.93% Twig 0.07%
doctrine entity-columns multi-search

petkoparamultisearchbundle's People

Contributors

petkopara avatar tacman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

petkoparamultisearchbundle's Issues

Add Simple search mode

Now the search is complex with word by word search.
Add support for simple one word or phrase search

Document installation for Symfony 5

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.

indexAction issue when searching when adding a new search variable by default

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);
    }

New release with only supported Symfony versions?

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.

Simple search form is not working

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.