itaym02 Posted September 14, 2009 Share Posted September 14, 2009 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"> Quote Link to comment https://forums.phpfreaks.com/topic/174219-solved-how-do-i-remove-form-attributes-in-zend-framework/ Share on other sites More sharing options...
thehippy Posted September 19, 2009 Share Posted September 19, 2009 Line: 51 /**#@+ * Encoding type constants */ const ENCTYPE_URLENCODED = 'application/x-www-form-urlencoded'; const ENCTYPE_MULTIPART = 'multipart/form-data'; /**#@-*/ Line: 786 /** * Set encoding type * * @param string $value * @return Zend_Form */ public function setEnctype($value) { $this->setAttrib('enctype', $value); return $this; } /** * Get encoding type * * @return string */ public function getEnctype() { if (null === ($enctype = $this->getAttrib('enctype'))) { $enctype = self::ENCTYPE_URLENCODED; $this->setAttrib('enctype', $enctype); } return $this->getAttrib('enctype'); } As you can see, you may actually be removing the attribute, but as soon as getEnctype() is accessed to write the element the attribute is being overridden. To remove the 'enctype' attribute just for the sake of removing it doesn't make much sense, it's better to explicitly set it so you and the browser have a better chance of getting data back in an expected format. I would argue that the default behaviour is preferred in this case . Quote Link to comment https://forums.phpfreaks.com/topic/174219-solved-how-do-i-remove-form-attributes-in-zend-framework/#findComment-921277 Share on other sites More sharing options...
itaym02 Posted September 20, 2009 Author Share Posted September 20, 2009 thanks Quote Link to comment https://forums.phpfreaks.com/topic/174219-solved-how-do-i-remove-form-attributes-in-zend-framework/#findComment-921686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.