Zend框架1提交表单url / action

时间:2013-03-07 04:48:19

标签: php zend-framework

我正在开发一个AJAX注册表单,该表单将提交给Zend Framework。现在,表单的操作似乎没有执行。响应文本是当前HTML文档的副本。有人可以告诉我我做错了什么,以及正确的URL应该是什么?我已经使用模块设置了项目。例如,以下示例中的正确网址是:'/ account / register / auth'

#application.ini
resources.router.routes.register.route = /register
resources.router.routes.register.defaults.module = account
resources.router.routes.register.defaults.controller = register
resources.router.routes.register.defaults.action = index

#application/modules/accout/controllers/RegisterController.php
<?php
    class Account_RegisterController extends Zend_Controller_Action{
        public function init(){
            $this->view->register = new Account_Form_Register();
        }

        public function indexAction(){

        }

        public function authAction(){
            $request = $this->getRequest();
            $form = new Account_Form_Register();

            if($request->isPost()){
                print('submit');
            }else{
                print('nothing yet');
            }
        }
    }
?>

#application/modules/account/views/scripts/register/index.phtml
<div class="register">
        <form id="registerForm">
            <h2 class="formHeader">Register</h2>

            <div class="floatLeft">
                <?php echo $this->register->fName; ?>
            </div>
            <div class="remaining">
                <?php echo $this->register->lName; ?>
            </div>

            <div class="floatLeft">
                <?php echo $this->register->uEmail; ?>
            </div>
            <div class="remaining">
                <?php echo $this->register->aEmail; ?>
            </div>

            <div class="">
                <?php echo $this->register->phone; ?>
            </div>

            <div class="floatLeft">
                <?php echo $this->register->oPassword; ?>
            </div>
            <div class="remaining">
                <?php echo $this->register->cPassword; ?>
            </div>

            <div id="formButton">
                <?php echo $this->register->submit; ?>
            </div>
        </form>
</div>

1 个答案:

答案 0 :(得分:-1)

正如我所说,也许您应该在执行AJAX操作时禁用视图处理,以便返回json_encode($some_data)而不是HTML内容。

尝试

$this->_helper->viewRenderer->setNoRender(true);

查看this article