【发布时间】:2016-04-22 17:05:58
【问题描述】:
我有一个如下所示的 loginAction:
public function loginAction(Request $request){
if($request->getMethod() == 'POST'){
$mail = $request->getContent('umail');
$pass = $request->getContent('upass');
$em = $this->getDoctrine()->getManager();
$rep = $em->getRepository('SystemBundle:User');
$user = $rep->findOneBy(array("email"=>$mail,"pass"=>$pass));
if($user){
$id = $user->getId();
$type = $user->getType();
return $this->render('@System/Pages/admin/index.html.twig');
}
}
提交表单后出现以下错误:
Controller "SystemBundle\Controller\SystemController::loginAction()" 要求您为 "$request" 参数提供一个值(因为没有默认值或因为在此参数之后有一个非可选参数)。
以下是路由:
system_login:
path: /login
defaults: { _controller: SystemBundle:System:login}
和形式:
<form method="POST" id="lgn" action="{{ path('system_login') }}">
<span class="fa fa-times close" onclick="lgn()" ></span><br />
<span>Login:</span>
<input type="email" placeholder="Email" required="required" name="umail" />
<input type="password" placeholder="Password" required="required" name="upass" />
<button type="submit">login</button>
</form>
请帮忙...
【问题讨论】:
-
你是否正确导入
Symfony\Component\HttpFoundation\Request类?
标签: php symfony symfony-forms