views:

329

answers:

3

I have a Form element:

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

As can be seen I use the removeAttrib method to remove the default enctype. But, when I echo the form I still get:

<form id="auth-form" enctype="application/x-www-form-urlencoded" action="/auth/resetpassword2" method="post">
+1  A: 

'enctype' is not an attribute in the Zend_Form sense. See the setEncType() method. I'm not sure that you can completely remove it without writing the HTML yourself though.

smack0007
A: 

I believe enctype="application/x-www-form-urlencoded" is on by default in order for file uploads to work in any case. Note that if you set the enctype to '' you won't be able to upload files via that form.

Vlad Andersen
+2  A: 

Check this out. Line 92 of Zend_Form_Decorator_Form:

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

So, if it's post, the enctype is automatically added. You could override the decorator and remove, though I'm not sure if there's anything wrong with having the enctype set.

Typeoneerror
It clashes with JS in IE
Itay Moav
Ah yeah, I think this is right answer. You could also just create your own form view helper to override the default one. If the EncType clashes with the JS can't you just change the EncType to match?
smack0007
Might be a fix: http://www.talkphp.com/javascript-ajax-e4x/1176-form-enctype-internet-explorer.html
Typeoneerror