I am creating a module to add banners. Now I have a problem when I want to edit a banner.
The problem is that when I click “save”, Magento creates a new banner and doesn’t modify the original banner. It happens when I modify something and if I don’t modify anything and click “save”.
I have another problem. I have an image fiel and it’s working great but when I click “edit”, it shows the preview image and the delete check box but the field is empty and if I save the banner it leaves the image field empty.
I hope you can help me. Thanks in advance, if you need more information ask me for it.
about the saving of your banner, adapt the following code to your situation:
What is important here is to use the registry when saving.
Check too that the banner id is provided in $data when saving. Your form.php must provide it, add the code below before $form->setValues(…) line:
Of course you have to validate the input of the users beforeSave. Use the protected method _beforeSave() in your banner model to implement these input validation or in the controller directly in the save action.