似乎我在这里遗漏了一些东西而且我一直收到以下信息:
##在呈现模板期间抛出异常("缺少一些必需参数(" fooId")以生成路由的网址" foo_edit" 。")在AdminFooBundle中:默认:base.html.twig在第1行。##
这是Controller的行动:
/**
* @Route("/{fooId}/edit", name="foo_edit", requirements={"fooId" = "\d+"})
* @param $fooId
*
* @return View
*/
public function editFooFormAction($fooId)
{
$foo = $this->getFooRepository()->findOneBy(['fooId' => $fooId]);
return $this->render(
"AdminFooBundle:Competition:show_foo.html.twig",
['foo' => $foo]
);
}
这是我的枝条文件:
{% extends 'FooAdminToolBundle:Default:base.html.twig' %}
{% block inner_main %}
{{ parent() }}
<form data-spy="scroll" data-target="#affix-nav" action="{{ path('foo_create') }}" method="post">
<button type="submit" style="position: absolute; left:-10000px;"></button>
{% include 'FooAdminBundle:Foo:foo_data.html.twig'%}
<button type="submit" class="btn btn-default">Add new foo</button>
</form>
{% endblock %}
我的猜测是问题在于扩展Default:base.html.twig,但我现在看不到:
{% set currentPath = path(app.request.attributes.get('_route')) %}
<!DOCTYPE html>
<html lang="en">
<head>
<title> {% block title %}Admin Tool{% endblock %}</title>
{% block stylesheets %}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
{% endblock %}
{% block headcss %}
{% endblock %}
{% block headjavascripts %}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body data-spy="scroll" data-target="#affix-nav">
{% include 'FooAdminBundle:Default:navbar.html.twig' %}
<div class="container">
{% block main %}{% endblock %}
<div class="row">
<div class="col-sm-9">
{% block inner_main %}{% endblock %}
</div>
<div class="col-sm-3">
<div id="options" data-spy="affix"></div>
</div>
</div>
</div> <!-- /main -->
答案 0 :(得分:0)
检查参数$ fooId是否有效。在你的路线是强制性的,也许因为缺少,所以会引发错误。