私はフォーム検索を行い、メソッドは 'GET'でなければなりません。問題は、私がGETを使用するとコントローラのフィールドデータにアクセスできないが、私がPOStメソッドを使用すると、フォームデータにアクセスできることである。メソッドがGETのときにフォームデータを取得する方法
このコントローラでのアクション:については
# app/config.routing.yml
recherche:
path: /recherche
defaults: { _controller: AppBundle:Controller:recherche }
methods: [GET]
:のrouting.ymlファイルで
/**
* @Route("/recherche")
* @Method({"GET","POST"})
*/
public function rechercheAction(Request $request)
{
、あるいはまた:
public function rechercheAction(Request $request)
{
//....
$form = $this->createForm(BaseRechercheType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$titre = $form->get('titre')->getData();
$date = $form->get('date')->getData();
$contenue = $form->get('contenue')->getData();
$publier = $form->get('publier')->getData();
$qb = $em->getRepository('AppBundle:Actualite')->listeRechercheBackend($titre, $date, $contenue, $publier);
$entities = $paginator->paginate($qb, $request->query->get('page', 1), 10);
}
//.....
}