I'm adding a feature in a custom module that should manage Offer incompatibilities: for a given offer ID, there could be N "incompatibility" rules.

Basically, the model is:

OfferID    IncompatibleOfferID    Active(Y/N)
1          13                     Y
1          22                     Y
2          21                     N

So, for a given rule you can have multiple association between offers.

In the Edit form I would like to have a grid (Widget) to select multiple "child" offers to bind with the "father" offer.

To achieve that, I created:


that is basically a Grid Widget, in fact it has all the grid methods like

public function _prepareCollection()
    $items = Mage::getModel('offer/offer')->getCollection();


Now I would like to add this grid to the Edit form to select multiple "child" offer at the time.

So, here is my [Module]/Block/Adminhtml/[MyModule]/Edit/Form.php :

    /** @var Varien_Data_Form $form */
    $form = new Varien_Data_Form(array(
        'id' => 'edit_form',
        'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
        'method' => 'post',
        'enctype' => 'multipart/form-data',

/** ETC ETC **/

$promoFieldset = $form->addFieldset('related_promo', array(
            'legend' => Mage::helper('offer')->__('Promozioni'))

$relatedProdsGrid = $this


The last line is giving me the error, because "addElement" method accept only Varien_Form_Data_Abstract as input. Plus, the grid is not working as it should, (no filter, no pagination, no limit)

Any ideas? Should I choose a different approach? Thanks


Use a multi-tabbed edit form, and configure a new tab to ONLY contain the grid.

Essentially you are creating a tab class that uses this declaration:

class My_Module_Block_Adminhtml_Something_Edit_Tab_Subelements
    extends Mage_Adminhtml_Block_Widget_Grid
    implements Mage_Adminhtml_Block_Widget_Tab_Interface {}

This tab extends from Mage_Adminhtml_Block_Widget_Grid instead of Mage_Adminhtml_Block_Widget_Form.


  • Edit Customer (Orders Tab, Shopping Cart Tab, etc)
  • Edit Product (Related Products Tab, etc)
  • Order View (Invoice, Shipments, etc are all grids inside a "form")
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.