0
我沒有什麼問題。登錄失敗後,我的symfony應用程序不會在登錄文件中顯示錯誤消息; /。輸入好登錄後& pasword everthing是好的,im登錄&重定向到儀表板。symfony 2.8登錄錯誤不顯示
對不起,我的英語:)
這裏是我的控制器
class LoginController extends Controller
{
/**
* @Route("/login", name="login")
*
* @Template()
*/
public function loginAction(Request $Request)
{
$Session = $this->get('session');
// Login Form
if($Request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)){
$loginError = $Request->attributes->get(SecurityContextInterface::AUTHENTICATION_ERROR);
}else{
$loginError = $Session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
}
if(isset($loginError)){
$this->get('session')->getFlashBag()->add('error', $loginError->getMessage());
}
$loginForm = $this->createForm(new LoginType());
return array(
'loginForm' => $loginForm->createView()
);
}
這裏是塊form_errors代碼視圖文件form_template.html.twig:
{% block form_errors %}
{% spaceless %}
{% if errors|length > 0 %}
{% for error in errors %}
<div class="alert alert-danger">
<button class="close" data-close="alert"></button>
<span> {{ error.message|trans }} </span>
</div>
{% endfor %}
{% endif %}
{% endspaceless %}
{% endblock %}
謝謝:)
執行傳入if(isset($ loginError)){? –