1

This is field i am using in Form.php

$fieldset->addField('item', 'select', array(
              'label'     => Mage::helper('frame')->__('Select Item'),
              'name'      => 'item',
              'values'    => Mage::getModel('frame')->toOptionArray(),
          ));

Here i wrote this function ..Block/Adminhtml/Frame.php

 public function toOptionArray()
    {
       $r_connection = Mage::getSingleton('core/resource')->getConnection('core_read');

            /* Write Select query */
            $sql = "SELECT * FROM manage_item";

            /* Run query*/
            $item_data = $r_connection->fetchAll($sql);

        $itemarray = array(
             array(
                'value'=>-1, 
                'label'=>'Please Select'
             )
        );
        foreach ($item_data as $itemList){
            $itemarray[] = array(
                   'value'=>$itemList['item_id'],
                   'label'=>$itemList['item_name']
            );
        }
        return $itemarray;
    }

I am getting internal server error here.any solution.

2

Mage::getModel('frame')->toOptionArray() is model class object but you have define the value at block class Block/Adminhtml/Frame so,it not works .

So you need to call function toOptionArray() using class of block class call

YouModuleNameSpace_YouModuleName_Block_Adminhtml_Frame::toOptionArray()

instead of

Mage::getModel('frame')->toOptionArray()
0

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.