我为此感到困惑。我有一个如下所示的登录操作:
public function loginAction()
{
$form = new Application_Form_Login;
$form->setAction("/users/login");
$request = $this->getRequest();
var_dump($request->isPost());
if ($request->isPost() && $form->isValid($request->getPost())) {
// snipped code that is never reached anyway
}
$this->view->form = $form;
}
表格:
class Application_Form_Login extends Zend_Form
{
public function init()
{
$this->setMethod("post");
$email = new Zend_Form_Element_Text("email");
$email->addFilter("StringTrim")
->addValidator("NotEmpty")
->addValidator("EmailAddress")
->setRequired(true)
->setLabel("Email address");
$this->addElement($email);
$password = new Zend_Form_Element_Password("password");
$password->addFilter("StringTrim")
->addValidator("NotEmpty")
->setRequired(true)
->setLabel("Password");
$this->addElement($password);
$submit = new Zend_Form_Element_Submit("finish");
$submit->setLabel("Login");
$this->addElement($submit);
}
}
var_dump($request->isPost())
总是返回false,但是在一个大致相同的动作中它完美地运行!有什么想法吗?
答案 0 :(得分:1)
我追踪了它。如果用户没有登录,我有/用户重定向到/ users / login。我没有将Zend_Auth的结果保存在存储中,因此给我的印象是登录无效。
POST http://localhost/users/login (302 Found)
GET http://localhost/users
GET http://localhost/users/login