doushe8577 2010-08-19 14:25
浏览 43
已采纳

ZF表格拒绝发布

I'm perplexed by this. I have a login action that looks like this:

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;
}

And a 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()) always returns false, yet in a mostly identical action it works perfectly! Any ideas?

  • 写回答

1条回答 默认 最新

  • douzi8916 2010-08-19 14:38
    关注

    I tracked it down. I had a redirect on /users to redirect back to /users/login if the user was not logged in. I wasn't saving the result of Zend_Auth in storage, thus giving me the impression login was doing nothing.

    POST http://localhost/users/login (302 Found)
    GET http://localhost/users
    GET http://localhost/users/login
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用