我在Symfony2上使用以下控制器代码的登录表单
public function loginAction(Request $request)
{
$user = new SiteUser();
$form = $this->createForm(new LoginType(), $user);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
$data = $form->getValues();
// Need to do something with the data here
}
return $this->render('GDSiteBundle::header.html.twig', array('form' => $form->createView()));
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下警告:
警告:array_replace_recursive()[function.array-replace-recursive]:参数#1不是\ vendor\symfony\src\Symfony\Component\Form\Form.php第593行中的数组500内部服务器错误 - ErrorException
有人可以帮我理解什么是不正确的,以及我如何解决它?谢谢.
更新:twig文件是这样的:
<div class="form">
{{ form_errors(form) }}
<form action="{{ path('site_user_login') }}" method="POST" {{ form_enctype(form) }}>
<div class="level1">
{{ form_row(form.username) }}
<a href="javascript:void(0)" id="inscription">{% trans %}Registration{% endtrans %}</a>
</div>
<div class="level2">
{{ form_row(form.pwd_hash) }}
<div class="forget_pass"><a …Run Code Online (Sandbox Code Playgroud)