如何在Zend Framework中删除表单属性?

时间:2009-09-14 15:51:58

标签: php zend-framework zend-form

我有一个Form元素:

$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 个答案:

答案 0 :(得分:4)

检查一下。 Zend_Form_Decorator_Form的第92行:

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

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

答案 1 :(得分:2)

$Form->setAttrib('enctype', null);

答案 2 :(得分:1)

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

答案 3 :(得分:0)

我认为默认情况下enctype="application/x-www-form-urlencoded"处于启用状态,以便文件上传在任何情况下都能正常工作。请注意,如果您将enctype设置为'',则无法通过该表单上传文件。

相关问题