0

I am trying to create a new configuration for checking postcodes. Is it possible to add so many postcodes rather than creating one text field So I can pick which ever postcode by using type="select"

1

As far as I understand your question, I would suggest you create a select or multi-select field in Configuration. From which you can select whichever postcode you like.

Add code for select/multi-select field in Namespace/Module/etc/adminhtml/system.xml something like,

<!-- For Select Type Configuration -->
<field id="postcode" translate="label" sortOrder="1" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
   <label>Select Postcode</label>
   <source_model>Namespace\Module\Model\Adminhtml\System\Postcode</source_model>
</field>


<!-- For Multiselect -->
<field id="postcode_multiselect" translate="label" sortOrder="2" type="multiselect" showInDefault="1" showInWebsite="1" showInStore="1">
   <label>Select Beauty Banners</label>
   <source_model>Namespace\Module\Model\Adminhtml\System\Postcode\Multiselect</source_model>
</field>

Created Source Model file to get ToArray function just like implemented in below link, https://magento.stackexchange.com/a/92863/45214

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.