2

我有一个表单元素:

$Form=new Zend_Form;
        $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true))
             ->setMethod('post')
             ->setAttrib('id','auth-form')
             ->removeAttrib('enctype');

可以看出我使用 removeAttrib 方法来删​​除默认的 enctype。但是,当我回显表单时,我仍然得到:

<form id="auth-form" enctype="application/x-www-form-urlencoded" action="/auth/resetpassword2" method="post">
4

4 回答 4

4

看一下这个。第 92 行Zend_Form_Decorator_Form

if ($method == Zend_Form::METHOD_POST) {
    $this->setOption('enctype', 'application/x-www-form-urlencoded');
}

因此,如果它是 post,则会自动添加 enctype。您可以覆盖装饰器并删除,但我不确定设置 enctype 是否有任何问题。

于 2009-09-14T17:00:58.270 回答
2
$Form->setAttrib('enctype', null);
于 2012-09-02T10:58:42.987 回答
1

'enctype' 不是 Zend_Form 意义上的属性。请参阅setEncType()方法。我不确定您是否可以在不自己编写 HTML 的情况下完全删除它。

于 2009-09-14T16:53:24.213 回答
0

我相信enctype="application/x-www-form-urlencoded"默认情况下是打开的,以便文件上传在任何情况下都能正常工作。请注意,如果您设置为enctype''您将无法通过该表单上传文件。

于 2009-09-14T17:00:03.300 回答