我想使用参数修改提交的symfony表单的url。从该平台尝试了许多解决方案,但没有解决方案有帮助!
当前网址如下:http://localhost:8000/search?app_bundle_search_form%5Bsearch%5D=qui&app_bundle_search_form%5Bbrand%5D=&app_bundle_search_form%5Bprice%5D=500%2C100000&app_bundle_search_form%5B_token%5D=BtA5bZb9HErUXzXFzGFbpEhlD6nD33zr7tKiPLxjpy4
我想要它像http:// localhost:8000 / search?search = qui?brand =?minprice = 500?maxprice = 100000
这是我的控制器:
public function searchAction($searchTerm=null,Request $request)
{
if ($request->getMethod() == 'GET') {
$searchTerm = $request->query->get('app_bundle_search_form')['search'];
$searchBrand = $request->query->get('app_bundle_search_form')['brand'];
$price = $request->query->get('app_bundle_search_form')['price'];
$price = explode(",", $price);
$minPrice = $price[0];
$maxPrice = $price[1];
$em = $this->getDoctrine()->getManager();
$search = $em->getRepository('AppBundle:Classified')->searchClassifieds($searchTerm, $searchBrand, $minPrice, $maxPrice);
}
return $this->render('search-result.html.twig', [
'searchTerm' => $searchTerm,
'results' => $search
]);
}
Run Code Online (Sandbox Code Playgroud)
形成:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->setMethod('GET')
->add('search', TextType::class,array(
'required'=> false …Run Code Online (Sandbox Code Playgroud)