Untuk memasukkan bidang negara yang diizinkan dalam konfigurasi modul khusus Anda:
tambahkan berikut ini ke system.xml modul Anda
<sallowspecific translate="label">
<label>Ship to Applicable Countries</label>
<frontend_type>select</frontend_type>
<sort_order>90</sort_order>
<frontend_class>shipping-applicable-country</frontend_class>
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</sallowspecific>
<specificcountry translate="label">
<label>Ship to Specific Countries</label>
<frontend_type>multiselect</frontend_type>
<sort_order>91</sort_order>
<source_model>adminhtml/system_config_source_country</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<can_be_empty>1</can_be_empty>
</specificcountry>
di bawah <fields>
tag di bagian kustom Anda.
Untuk menambahkannya di formulir admin:
di app / code / local / Yourmodulename / Block / Adminhtml / Yourmodulename / Edit / Tab / Form.php
$countryList = Mage::getModel('directory/country')->getResourceCollection()->loadByStore()->toOptionArray(true);
$fieldset->addField('allowed_countries', 'multiselect', array( /* "allowed_countries" is the column name in your custom table to store these values */
'name' => 'countries[]',
'label' => Mage::helper('yourmodulename')->__('Allowed Countries'),
'title' => Mage::helper('yourmodulename')->__('Allowed Countries'),
'required' => true, /* only if it is required */
'values' => $countryList,
));
catatan:
- Anda harus menulis logika untuk menyimpan nilai multiseleksi dalam database di saveAction ()
untuk menampilkan ini di kisi admin:
lihat tautan ini .