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.
Best Answer
Mage::getModel('frame')->toOptionArray()
is model class object but you have define the value at block classBlock/Adminhtml/Frame
so,it not works .So you need to call function toOptionArray() using class of block class call
instead of