這是佈線後的路由信息:如何在Symfony中傳遞參數?
cacic_uorg_type_excluir:
pattern: /uorg/type/excluir/{idUorgType}
defaults: { _controller: CacicCommonBundle:UorgType:excluir, idUorgType: null}
requirements:
idUorgType: \d+
這是我的控制器
public function excluirAction($idUorg, Request $request)
{
if (! $request->isXmlHttpRequest())
throw $this->createNotFoundException('page not found');
$uorgType = $this->getDoctrine()->getRepository('CacicCommonBundle:TipoUorg')->find($request->get('id'));
if (! $uorgType)
throw $this->createNotFoundException('UORG nor found');
$em = $this->getDoctrine()->getManager();
$em->remove($uorgType);
$em->flush();
$response = new Response(json_encode(array('status' => 'ok')));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
但我不斷收到錯誤
Controller "Cacic\CommonBundle\Controller\UorgTypeController::excluirAction()" requires that you provide a value for the "$idUorg" argument (because there is no default value or because there is a non optional argument after this one).
感謝您的幫助,但這個錯誤仍然沒有任何變化 –