如果表单是有效的Zend Framework,则重定向

时间:2012-10-24 13:40:12

标签: php zend-framework

在下面的代码中,我检查表单是否有效,如果是,我希望它重定向到下一页,但是它会给出以下错误: 发生错误 网页未找到 例外信息: 消息:指定的控制器无效(未定义)

以下是代码:

public function indexAction()
    {
        global $current_user;

        if ( is_user_logged_in() ) {
            $mapper = new Site_Model_WpTerms();
            $main_categories = $mapper->fetchTerms(0,'ptype',true);
            $sizes = $mapper->fetchTerms(0,'size',true);
            $genders = $mapper->fetchTerms(0,'gender',true);
            $seasons = $mapper->fetchTerms(0,'season',true);
            $decades = $mapper->fetchTerms(0,'decade',true);
            $colors = $mapper->fetchTerms(0,'color',true);
            $styles = $mapper->fetchTerms(0,'style',true);
            $materials = $mapper->fetchTerms(0,'material',true);
            $patterns = $mapper->fetchTerms(0,'pattern',true);
            $others = $mapper->fetchTerms(0,'other',true);
            $condition = $mapper->fetchTerms(0,'condition',true);
            $shipping = $mapper->fetchTerms(0,'shipping',true);
            $this->view->colors = $colors;
            $form = new Site_Form_Submission($main_categories,$sizes,$genders,$seasons,$decades,$colors,$styles,$materials,$patterns,$others,$condition,$shipping);
            $this->view->form = $form;
            $this->view->finished_settings = self::finishedStep('finished_settings');

            if ($this->getRequest()->isPost()) {
                if (!$form->isValid($this->getRequest()->getParams())) {
                    $form->populate($this->getRequest()->getParams());
                }else{
                    $this->_helper->redirector('getpaid');
                }
            }
        }
        else{
            $this->_redirect('http://' . $_SERVER['HTTP_HOST'] . PHOTO_GUIDE);
        }
    }

我必须提到我在我的应用程序中使用模块。 任何帮助将非常感激!

2 个答案:

答案 0 :(得分:1)

请尝试以下代码:

$redirector = $this->_helper->getHelper('Redirector');

$this->_redirector->setCode(303)
    ->setExit(false)
    ->setGotoSimple("this-action", "some-controller");

答案 1 :(得分:0)

试试这个$this->_helper->redirector('action','controller','module');