我有一个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">
答案 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
设置为''
,则无法通过该表单上传文件。