在Magento的Admin中显示值

时间:2015-05-29 11:08:09

标签: php forms magento

我从管理面板添加区域设置添加工作完美但我想在编辑中显示值如何实现此目的?

这是我的代码:

<?php 

foreach (Mage::app()->getWebsites() as $webs) {
                $fieldset->addField(str_replace(' ','_',$webs->getName()), 'note', array(

                'label'     => $webs->getName(),
                'fieldset_html_class' => 'website',
            ));
        foreach ($webs->getGroups() as $groups) {

            $fieldset->addField(str_replace(' ','_',$groups->getName()), 'note', array(

                'label'     => $groups->getName(),
                'fieldset_html_class' => 'store-group',
            ));
            $stores = $groups->getStores();
            foreach ($stores as $store) {

                $fieldset->addField('region_'.Mage::getStoreConfig('general/locale/code', $store->getId()), 'text',  array(
                'name'      => 'region_'.Mage::getStoreConfig('general/locale/code', $store->getId()),
                'fieldset_html_class' => 'store',
                'label'     => $store->getName(),
                'title'     => $store->getName(),


            ));
              }}}

?>

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

您必须以 form-&gt; addValues

添加数据
$id = $this->getRequest()->getParam('id');




 if($id){
    $resource = Mage::getSingleton('core/resource');
    $read = $resource->getConnection('core_read');
    $table = $resource->getTableName('directory/country_region_name');
    $allrecord = $read->select()->from(array('regions'=>$table))->where('regions.region_id=?', $region_id);
    $data =$read->fetchAll($allrecord);
    foreach($data as $rows)
    {

    $form->addValues(array('region_'.$rows['locale']=> $rows['name']));
    }

}