Page tree
Skip to end of metadata
Go to start of metadata

First lets suppose you created a custom module with the module creator.

Then in /app/code/local/Company/ModName/Block/Adminhtml/ModName/Edit/Form.php

Add ‘enctype’ ⇒ ‘multipart/form-data’ That should help to get something in $_FILES

You should have something looking like this:

 Expand source

Then in /app/code/local/Company/ModName/Block/Adminhtml/ModName/Edit/Tab/Form.php

in _prepareForm Add your upload field (you can add a field of type file (any file) image (image with a “preview” and a checkbox to delete) or imagefile for vidéos !

 Expand source

Then in /app/code/local/Company/ModName/controllers/Adminhtml/ModuleNameController.php again after if ($data = $this→getRequest()→getPost()) { in saveAction()


 Expand source

if you are using an image field type, (image is set in addField), then you should add the following code after the if in the controller code. It will now handle a “delete” checkbox linked to the upload field.

 Expand source

That's it! You're done!

  • No labels