Magento – How to get country list in system.xml

magento2magento2.2system.xml

I want to display list of country in my system.xml

<field id="country" translate="label" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Countries</label>
</field>

How we do this?

Best Answer

Use class Magento\Directory\Model\Config\Source\Country for country list

<field id="specificcountry" translate="label" type="multiselect" sortOrder="16" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Ship to Specific Countries</label>
    <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
    <can_be_empty>1</can_be_empty>
</field>
Related Topic