需要 Zend 框架操作堆栈帮助


zend framework action stack help needed

我在采埃孚应用程序中使用了action stack。我将在这里解释场景。在第一个操作中,我有带有选择框和提交按钮的简单表单。现在在帖子中,我验证数据并在action stack中保存并推送我的第二个操作。

我在堆栈中推送的第二个操作也是有一个表单,该表单将在发布时保存数据。

现在问题出现在这里:当操作堆栈被处理时,它会弹出堆栈并转发存储在堆栈中的第二个操作。现在,当我的第二个操作被调用时,它直接进入 post 中的循环并尝试验证数据,因为第一个操作请求是 post,并且我没有从第二个操作中获得表单。

我知道动作堆栈是邪恶的,但到目前为止,我没有其他选择。 这只是我试图解释我的问题的一种情况。

如果我无法正确解释问题,我很乐意更详细地解释......

public function firstactionAction() {
    if($this->getRequest()->isPost()) {
        //validate and save form
        $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('actionStack');
        $request = new Zend_Controller_Request_Http();
        $request->setControllerName('index');
        $request->setModuleName('default');
        $request->setActionName('secondaction');
        $helper->pushStack($request);
    } else {
        //creating form object and assigning to view.
    }
}
public function secondactionAction() {
    if($this->getRequest()->isPost()) {
        //Problem is here.. when action stack gets processed.. it directly comes here. as it uses forward internally..
    } else {
        //creating form object and assigning to view.
    }
}

提前感谢...

我看到了一个简单的方法:只需为每个表单添加一个简单的隐藏字段并执行下一个条件:

if($this->getRequest()->isPost() && $this->getRequest()->getPost('hidden') == 'second_form') {
    // ...
}