2012-08-02 7 views
1

사용자 이름, 비밀번호 및 확인과 함께 제출하는 3 가지 입력과 함께 로그인 양식이 있습니다. 사용자 이름이나 암호가 비어 있으면 유효성 검사가 올바르게 실패합니다. 그러나 Chrome에서는 양식을 다시 제출할 수 없습니다. 제출을 클릭해도 아무 효과가 없습니다. IE와 Firefox에서는 잘 작동합니다.유효성 검사가 실패한 후 Zend 양식 제출이 작동하지 않습니다 - Chrome에서만

Zend Controller Action: 

public function loginAction() 
    { 
     $this->_helper->layout->setLayout('layout_nomenu'); 
     $loginForm = new Application_Form_Login(); 

     $request = $this->getRequest(); 
     if ($request->isPost()) { 

      if ($loginForm->isValid($request->getPost())) { 

       $valid = false; 
       if ($valid) { 
       //if ($this->_process($loginForm->getValues())) { 
        $this->_helper->redirector('users', 'grid'); 
       } else { 
        $this->view->loginfail = "Login details not recognised, please try again"; 
       } 
      } 
     } 
     $this->view->login = $loginForm; 
    } 

forms.ini: 

[login] 
action = "login" 
method = "post" 
name = "login" 

elements.username.type = "text" 
elements.username.options.label = "Username:" 
elements.username.options.validators.strlen.validator = "StringLength" 
elements.username.options.validators.strlen.options.min = "2" 
elements.username.options.validators.strlen.breakChainOnFailure = "true" 
elements.username.options.required = "true" 

elements.password.type = "password" 
elements.password.options.label = "Password:" 
elements.password.options.validators.strlen.validator = "StringLength" 
elements.password.options.validators.strlen.options.min = "2" 
elements.password.options.validators.strlen.breakChainOnFailure = "true" 
elements.password.options.required = "true" 

elements.submit.type = "submit" 
elements.submit.options.label = "Login" 

displayGroups.loginform.elements.username = "username" 
displayGroups.loginform.elements.password = "password" 
displayGroups.loginform.elements.submit  = "submit" 
displayGroups.loginform.options.legend  = "Login" 

Login form: 

class Application_Form_Login extends Zend_Form 
{ 
    public function init() 
    { 

     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini', 'login'); 
     $this->setOptions($config->toArray()); 
     //$this->addElement('hash', 'no_csrf_foo', array('salt' => 'unique')); 

    } 
} 

HTML은 매우 간단합니다 - 아니 JS 등 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<title>Development </title> 



<link href="/css/global.css" media="screen" rel="stylesheet" type="text/css" /><link href="/css/global.css" media="screen" rel="stylesheet" type="text/css" /> 

<link href="/css/development.css" media="screen" rel="stylesheet" type="text/css" /> 

</head> 

<body> 

    <div id="header"> 

     <div id="header-logo" style="float: left"><img src="/images/small.gif" alt="Development" style="margin-top:5px" />&nbsp;&nbsp;Development</div> 

     <div id="header-navigation" style="float: right"> 

     </div> 

    </div> 



    <div id="view-content"> 
<div id="loginform"> 
<form id="login" enctype="application/x-www-form-urlencoded" action="login" method="post"><dl class="zend_form"> 

<dt id="loginform-label">&#160;</dt><dd id="loginform-element"><fieldset id="fieldset-loginform"><legend>Login</legend> 

<dl> 

<dt id="username-label"><label for="username" class="optional">Username:</label></dt> 

<dd id="username-element"> 

<input type="text" name="username" id="username" value="a" /> 

<ul class="errors"><li>'a' is less than 2 characters long</li></ul></dd> 

<dt id="password-label"><label for="password" class="optional">Password:</label></dt> 

<dd id="password-element"> 

<input type="password" name="password" id="password" value="" /></dd> 

<dt id="submit-label">&#160;</dt><dd id="submit-element"> 

<input type="submit" name="submit" id="submit" value="Login" /></dd></dl></fieldset></dd></dl></form> <div id="loginerror"> 
     </div> 
</div> 
<div id="loginspacer">&nbsp;</div> 
</div> 


<div id="footer"> 

<div id="footer-logo"></div> 

<div id="footer-navigation">Quetzal Technology 2012</div> 

</div> 

</body> 

</html> 
+0

페이지가 어디에 살고 있습니까? –

+0

테스트를 위해 새 도메인을 주문했습니다. 내일 사용할 수 있습니다. – Leopard

답변

0

은 어쩌면 조금 더 간단 시도하고 어떻게되는지 :

public function loginAction() 
    { 
     $this->_helper->layout->setLayout('layout_nomenu'); 
     $loginForm = new Application_Form_Login(); 

     $request = $this->getRequest(); 
     if ($request->isPost()) { 

      if ($loginForm->isValid($request->getPost())) { 

        $this->_helper->redirector('users', 'grid'); //go here if valid     
      } else { 
      //go here if not valid 
      $this->view->loginfail = "Login details not recognised, please try again"; 

      }   

     } 
     //if not post show form 
     $this->view->login = $loginForm; 
    } 

것은 내가 그 여분 궁금해해야 루프가 일부 인스턴스에서 문제를 일으킬 수 있습니다.

+0

여전히 문제가있는 것 같습니다. *주의 isValid 양식 메서드를 재정의하지 않았습니다. "// if ($ this -> _ process ($ loginForm-> getValues ​​())) { "이것은 유효성 검사 후 – Leopard

+0

신비하게 고쳐졌습니다 - 이유를 알 때 업데이트됩니다. – Leopard

관련 문제