zend框架:在表单类中设置操作

发布于 2025-01-05 12:00:25 字数 401 浏览 5 评论 0原文

我有一个 Zend Framework 应用程序,并且我一直在表单类中设置表单操作。

class Form_Nieuws_AddForm extends Zend_Form {

    public function init() {
    $this->setMethod('get');
    $this->setAction('/test/blaat');
    $this->setAttribs(array(
        'id' => 'frmCreate',
        'class' => 'baal'
    ));
            ....
    }
}

属性设置好了,但是动作和方法不行? 如果我将它们移至控制器,它就可以正常工作。怎么会?

I have a Zend Framework application and I am stuck with setting the form action in the form class.

class Form_Nieuws_AddForm extends Zend_Form {

    public function init() {
    $this->setMethod('get');
    $this->setAction('/test/blaat');
    $this->setAttribs(array(
        'id' => 'frmCreate',
        'class' => 'baal'
    ));
            ....
    }
}

The attribs are set just fine, but the action and method not?
If I move these to the controller it works just fine. How come?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2025-01-12 12:00:25

如果我在你那里,我会使用 Zend_Form 常量在表单 init 方法中设置方法,如下所示:

$this->setMethod(self::METHOD_POST);

并使用正确的方法来构造 url 的控制器中的操作:

$Form->setAction($this->view->url(array('controller' => 'test', 'action' => 'blaat'), 'default', TRUE));

If I where you, I would set the method in the form init method using the Zend_Form costants like this:

$this->setMethod(self::METHOD_POST);

and the action in the controller using the proper method to costruct the urls:

$Form->setAction($this->view->url(array('controller' => 'test', 'action' => 'blaat'), 'default', TRUE));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文