-1
だから私はアイテムを並べ替えるだろう、このChoiceType Form
持っている:$products = "SELECT a FROM AppBundle:Product a ORDER BY a.title ASC"
:ハンドル要求:ChoicesType
$sort = $this->createForm(ChoiceType::class, NULL, array(
'choices' => array(
'...' => 'default',
'A-Z' => 'title_up',
'Z-A' => 'title_down',
'Price low to high' => 'price_up',
'Price high to low' => 'price_down',
),
));
を、私はそれらの一つは、ドロップダウンメニューから選択されたときにようにChoices
を使用するには、これを行います。
私はこれを試してみました:定義されていないので、
$sort->handleRequest($request);
if($sort->isSubmitted() && $sort->isValid()) {
if (isset($default)) {
$products = "SELECT a FROM AppBundle:Product a ORDER BY a.title ASC";
return $this->render('AppBundle:main:index.html.twig', array('products' => $products,));
}
}
しかし$default
は、機能していません。私はchoices
にアクセスする方法を知らないので、if
ステートメントにそれらを渡すことができます。