How to remove form attributes in Zend Framework?

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 you can see, I am using the removeAttrib method to remove the default enctype. But, when I iterate over the form I still get:

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

      

+2


source to share


4 answers


Check it. Line 92 Zend_Form_Decorator_Form

:

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

      



So, if it is published, the enctype is automatically added. You can override the decorator and remove, although I'm not sure if anything is wrong if you have enctype set.

+4


source


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

      



+2


source


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

+1


source


I suppose this is enctype="application/x-www-form-urlencoded"

enabled by default so that file uploads can work anyway. Please note that if you install enctype

on ''

, you will not be able to upload files through this form.

0


source







All Articles