title: Magento - Modify Form Enctype via Event Observers
body: <p>I'm trying to add extra attributes to CMS pages. I am able to add these extra fields by following the help at <a href="http://blog.flexishore.com/2011/08/add-custom-field-to-cms-page/" rel="nofollow">http://blog.flexishore.com/2011/08/add-custom-field-to-cms-page/</a>.</p>
  
  <p>However, I cannot add images as the form for CMS pages does not have the enctype="multipart/form-data". To get around this I am having to create a local copy of the original Magento file. \app\code\local\Mage\Adminhtml\Block\Cms\Page\Edit\Form.php</p>
  
  <p>Ideally, I would like to inject the enctype using the observer. I have trolled around everywhere and haven't come across a suitable solution.</p>
  
  <p>I was hoping to be able to add something like $form->setHtmlAttributes('enctype', 'multipart/form-data')</p>
  
  <pre><code>  public function prepareFormMainTab(Varien_Event_Observer $observer)
    {
      $form = $observer-&gt;getEvent()-&gt;getForm();
  
      $fieldset = $form-&gt;addFieldset('fieldset', array(
          'legend' =&gt; 'CMS Extras',
          'class' =&gt; 'fieldset-wide'
              )
      );
  
      $fieldset-&gt;addField('imagefile', 'image', array(
          'name' =&gt; 'imagefile',
          'label' =&gt; 'Image',
          'title' =&gt; 'Image'
      ));
    }
  </code></pre>