Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a magento widget form to enctype="multipart/form-data" for file upload?
    primarykey
    data
    text
    <p>I am trying to make a widget for a gallery as all the modules I have seen don't really do what I am after and widgets seem like the way forward to allow the end user to have nice and easy control over placement.</p> <p>So so far I have followed the Magento how to make a widget tutorial:</p> <p><a href="http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-magento-widget-part-2/" rel="nofollow">http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-magento-widget-part-2/</a></p> <p>which has allowed me to set up the files I need and have things recognised in the back end.</p> <p>Now I can add an image upload field through the code below but the file does not get uploaded, this is it seems due to enctype="multipart/form-data" not being set automatically when I add a file field.</p> <p>So I looked about and it seems you can add a helper block for the widget form</p> <p>local/WebsiteDevelopment/GalleryWidget/etc/Widget.xml</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;widgets&gt; &lt;WebsiteDevelopment_GalleryWidget type="widgets/list" translate="name description" module="GalleryWidget"&gt; &lt;name&gt;Banner Gallery&lt;/name&gt; &lt;description&gt;Adds a full page width gallery&lt;/description&gt; &lt;parameters&gt; &lt;enabled_services&gt; &lt;label&gt;Enabled Services&lt;/label&gt; &lt;visible&gt;1&lt;/visible&gt; &lt;required&gt;1&lt;/required&gt; &lt;type&gt;multiselect&lt;/type&gt; &lt;source_model&gt;WebsiteDevelopment_GalleryWidget_Model_Services&lt;/source_model&gt; &lt;/enabled_services&gt; &lt;helper_block&gt; &lt;type&gt;WebsiteDevelopment/GalleryWidget_Adminhtml_Edit_Form&lt;/type&gt; &lt;/helper_block&gt; &lt;template translate="label"&gt; &lt;label&gt;Frontend Template&lt;/label&gt; &lt;visible&gt;1&lt;/visible&gt; &lt;required&gt;1&lt;/required&gt; &lt;type&gt;select&lt;/type&gt; &lt;values&gt; &lt;text translate="label"&gt; &lt;value&gt;GalleryWidget/view.phtml&lt;/value&gt; &lt;label&gt;Text Links&lt;/label&gt; &lt;/text&gt; &lt;/values&gt; &lt;/template&gt; &lt;image&gt; &lt;label&gt;Image One&lt;/label&gt; &lt;description&gt;The first image for the banner&lt;/description&gt; &lt;visible&gt;1&lt;/visible&gt; &lt;type&gt;image&lt;/type&gt; &lt;/image&gt; &lt;/parameters&gt; &lt;/WebsiteDevelopment_GalleryWidget&gt; &lt;/widgets&gt; </code></pre> <p>so after i add my helper block into the params section of the xml above i create my helper at WebsiteDevelopment/GalleryWidget/Block/Adminhtml/Edit/Form.php (which i think is where it should be, i am still unsure whether a block has to be in a specific structure like this for use in the backend ) and then add the following code</p> <p>WebsiteDevelopment/GalleryWidget/Block/Adminhtml/Edit/Form.php</p> <pre><code>&lt;?php class WebsiteDevelopment_GalleryWidget_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { protected function _prepareForm() { $form = new Varien_Data_Form(array( 'id' =&gt; 'edit_form', 'enctype' =&gt; 'multipart/form-data' )); $form-&gt;setUseContainer(true); $this-&gt;setForm($form); return parent::_prepareForm(); } } </code></pre> <p>obviously the form will need some more attributes to work fully but I was just hoping to get some different attributes on to the form so I could make sure the block was being applied.</p> <p>So at the moment when I go into the back end the form with the helper on it has no enctype still, and I am unsure if my helper block is even being loaded or whether it is and its just having no effect.</p> <p>Am I going about this in the correct manner or not?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload