2016-03-04 47 views
1

嗨,我正在学习树枝,我卡住了。它不检查表单是否被提交,所以我的猜测是不正确的。 任何人都可以指点我一个正确的方式。苗条树枝检查方法=张贴

{% if method == 'POST' %} 
Method posted 
{% endif %}ˇ 

我get函数

$app->get('/p/:id', function ($id) use ($app) { 

    $pDItem = $app->pD->where('id', $id)->first(); 

    if (!$pDItem) { 
     $app->notFound(); 
    } 

    $app->render('pD/pDItem.php', [ 
     'pDItem' => $pDItem, 
     'method' => $app->request->getMethod() 
    ]); 

})->name('pD.item'); 

-

回答

2

您需要改用:

$app->post('/p/:id', ...); 

或同时POSTGET方法匹配:

$app->map(['POST','GET'], '/p/:id', ...);