2

i am adding a locale for region from admin panel add is working perfectly but i want to show the value in edit how can i achieve this?

here is my code:

<?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(),       
            ));
        }}}    
?>
  • I have no idea what you are talking about. adding a region for what? Customer? shop? Product? and where do you want to show it? Where did you put the code? Please EDIT your question and add the informations – Fabian Blechschmidt May 29 '15 at 11:17
  • @FabianBlechschmidt i am creating the region manager extension, and i am facing issue. i have put my code that i have tried so far. – Raja Usman Mehmood May 29 '15 at 11:20
2

you have to add the data in form->addValues

get the param

$region_id = $this->getRequest()->getParam('id');




 if($region_id){
    $connectionresource = Mage::getSingleton('core/resource');
    $readconnection = $connectionresource->getConnection('core_read');
    $table = $connectionresource->getTableName('directory/country_region_name');
    $allrecord = $readconnection->select()->from(array('regions'=>$table))->where('regions.region_id=?', $region_id);
    $alldata =$readconnection->fetchAll($allrecord);
    foreach($alldata as $rows)
    {
    //'region_'.$rows['locale'] for you froms name
    $form->addValues(array('region_'.$rows['locale']=> $rows['name']));
    }

}

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.