在提交按钮上单击zendphp中未找到的状态代码


on submit button click the status code not found in zend php

我是php和zend框架的新手,请帮我解决这个问题。

我正试图使用zend构建一个注册表,单击提交按钮后,控件转到操作,但$this->_request->isPost()返回false,并且在chrome浏览器的网络选项中选中时会看到未找到的状态代码。

控制器

public function firstAction()
    {   
        $request = $this->getRequest();
        //die("inside first");
        Zend_Debug::dump($this->_request->isPost());
        //Zend_Debug::dump($indexForm->isValid($this->getRequest()->getPost()));

        //send the url after the form action
        $options =array("actionUrl"=>'/index/first',"header"=>'test');       
        //connecting the form and the view 
        $indexForm2 = new Application_Form_Login($options);
        //$page = $this->_request->getParam('page');

        if(($this->getRequest()->isPost())){ 
            if ($indexForm2->isValid($request->getPost()))
            {
                $regvalues=$this->getAllParams();               
                $modleinsert= new Application_Model_First(); //Create a modele object               
                $testreg= $modleinsert->getRegInsert($regvalues); 
                $testreg=1;
                if($testreg)
                {
                    $_SESSION['echo'] = "Saved successfully";   
                }
                else 
                {
                    $_SESSION['echo'] = "Please try again";
                }   
        }
        }
        $this->view->indexForm2 = $indexForm2;  
    }

表单代码

<?php
class Application_Form_Login extends Zend_Form
{
   public function init($options=NULL) 
    {
        //form
        $this->setAttrib("horizontal", true);
        $this->removeDecorator("DtDdWrapper");
        $this->setAction($options['actionUrl']) //controler name and action name(function name)
        ->setMethod('post')
        ->setName('form');

        /*$this->setAttribs(array('horizontal'=> true,'method'=>'post'))
        ->setAction($options['actionUrl'])
        ->setName('Calendar');*/

        /* First Name*/
        $this->addElement("text", "txtName", array(
                "required" => true,
                "label" => "First Name",
                'filters' => array('StringTrim'),
                //              "size"=>"10",  
                'validators' => array(array('NotEmpty', true, array('messages' => 'Please enter first name')))));
        //Last Name
        $this->addElement("text", "txtLastName", array(
                "required" => true,
                "label" => "Last Name",
                'filters' => array('StringTrim'),               
                'validators' => array(array('NotEmpty', true, array('messages' => 'Please enter last name')))));
        //district... dropdown
        $district=new Application_Model_First();
        $disList=$district->getDistrictsList(); //obtain the list of districts from db.
        $this->addElement("select", "ddlDistrict", array(
                "required" => true,
                "label" => "District",
                'filters' => array('StringTrim'),           
                'MultiOptions'=>$disList,               
                'validators' => array(array('NotEmpty', true, array('messages' => 'Please enter district name')))));

        //Register button
        $this->addElement("submit", "Submit", array("label" => "Submit"));
    }   
}

您正在创建变量$request,然后调用$this->_request。

由于使用相同的操作,您只需要调用$request->isPost