PUGX / PUGXAutoCompleterBundle

Add an autocomplete field to your Symfony forms
GNU Lesser General Public License v3.0
93 stars 38 forks source link

Documentation : searchCityAction #25

Closed ybensacq closed 8 years ago

ybensacq commented 8 years ago

For beginners, I think the following lines are insufficient :

public function searchCityAction(Request $request)
    {
        $q = $request->get('term');
        $em = $this->getDoctrine()->getManager();
        $results = $em->getRepository('AppBundle:GeoCity')->findLikeName($q);

        return array('results' => $results);
    }

Why not add the following annotation : * @Template(":folder:city.html.twig") or rendering a template like they said in best practices ? :)

ybensacq commented 8 years ago

another problem

public function searchBookAction(Request $request)
    {
        // the following line should be 
        $q = $request->get('q'); 
       // instead of 
       // $q = $request->get('term'); 
        $em = $this->getDoctrine()->getManager();
        $results = $em->getRepository('AppBundle:Book')->findLikeName($q);

        return array('results' => $results);
    }