Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6725999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:52:27+00:00 2026-05-26T09:52:27+00:00

I am creating a module to add banners. Now I have a problem when

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:52:28+00:00Added an answer on May 26, 2026 at 9:52 am

    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:

    $model = Mage::registry('BannerManagement_data');
    if ($model->getEntityId()) {
       $fieldset->addField('entity_id', 'hidden', array('name' => 'entity_id'));// or banner_id depends on what id title you gave in your database table
    }
    

    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.

    /**
     * Common init to almost all actions
     */
    protected function _initAction(){
        $this->_title ($this->__("Banner"));
    
        $this->loadLayout();
        $this->_setActiveMenu('mymenu/banner');
        $this->_addBreadcrumb(Mage::helper('banner')->__('Banners'), Mage::helper('banner')->__('Items'));
        }
    
        if(! Mage::registry('current_banner')){
            Mage::register('current_banner', Mage::getModel('banner/item'));
        }
    
        $id = $this->getRequest()->getParam('id');
        if (!is_null($id)) {
            $model = Mage::registry('current_banner')->load($id);
    
            if (! $model->getId()) {
                $this->_getSession()->addError(Mage::helper('banner')->__('This banner item no longer exists'));
                $this->_redirect('*/*/');
                return;
            }
        }
    
        return $this;
    }
    
    
    /**
     * Banner edit page
     */ 
    public function editAction(){
        $this->_initAction();
        $this->_title('Banner Edit');
    
        // 1. Get ID and create model
        $banner = Mage::registry('current_banner');
    
        // 2. set entered data if there had errors when we do save
        $data = $this->_getSession()->getBannerData(true);
    
        // 3. restore data from SESSION and provide a correct date format
        if (!empty($data)) {
            $banner->addData($data);
        }
    
        // 4. Build Edit form
        $this->_addBreadcrumb(Mage::helper('banner')->__('Edit banner Item'), Mage::helper('banner')->__('Edit Banner Item'));
        $this->_addContent($this->getLayout()->createBlock('banner/adminhtml_banner'));
        $this->renderLayout();
    }
    
    /**
     * Subscritpion save process
     */ 
    public function saveAction(){
    
        $this->_initAction();
        $banner = Mage::registry('current_banner');
        $data = $this->getRequest()->getParams();
    
        if ($data) {
    
            try {
                $banner->addData($data);
                $banner->save();
    
                $this->_getSession()->addSuccess(Mage::helper('banner')->__('The banner item has been saved.'));
    
                if ($this->getRequest()->getParam('back', false)) {
                    $this->_redirect('*/*/edit', array('id'    => $banner->getId(), '_current'=>true));
                    return;
                }
            } catch (Exception $e) {
                $this->_getSession()->addError($e->getMessage());
                $this->_getSession()->setBannerData($banner->getData());
                $this->_redirectUrl($this->getUrl('*/*/edit', array('id' => $banner->getId())));
                return;
            }
        }
        $this->_redirectUrl($this->getUrl('*/adminhtml_overview'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a module that let's your users add feeds. So i want my
I want to add known JPA entities programatically when creating EntityManagerFactory. So I have
I'm creating an admin module for my client that gives them access to some
In Magento I'm creating a custom module and would love to be able to
I am creating a module that needs to tag nodes with taxonomy terms when
If I am creating a ASP.NET Website, how i can add blogging module using
Using Rails 2.3.11 , I'm creating a plugin for Redmine that add methods to
Picture this: you are creating a little module that people can incorporate into their
I'm creating a simple API that creates typed classes based on JSON data that
I need to create module in Magento which will have few database tables. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.