0

I've added some fields in a form using an array as source:

 $addInternalInformation->addField(
        'return_type', 'select',
        array(
            'name'  => 'return_type',
            'label' => $this->__('Return type'),
            'values' => Mage::getModel('modulename/source_returntype')->toOptionArray()
        )
    );

Now I'd like to show that values in the grid instead of the index, should I use a Render Class or there is a simpler method?

Thanks

3

I solved creating a _toOption() function to use inside the addColumn grid method:

$this->addColumn(
            'return_type',
            array(
                'header'  => 'return_type',
                'index' => 'return_type',
                'type' => 'options',
                'options' => $this->_toOptions(Mage::getModel('modulename/source_returntype')->toOptionArray())

            )
        );

protected function _toOptions($optArray){
        $options=array();
        foreach ($optArray as $option){
            $options[$option['value']] = $option['label'];

    }
  • The other solution is create the function toArray in Mage::getModel('modulename/source_returntype') and process data with format. – jruzafa Mar 2 '16 at 11:42

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.