You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';
}
}
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
Form Type
View
Did i miss anything else?
The text was updated successfully, but these errors were encountered: