I have a simple question about handling Country and Region dropdowns in admin form. Do I need to create two EAV attributes for region and region_id and put dropdown value in region_id and custom region value in region field. Can't I use the same attribute, some how. Is there a good tutorial which handles the scenario.

  • I believe you should take a look into: magento.stackexchange.com/a/181621 – Łukasz Oct 30 '17 at 21:15
  • I already did this. This gives me form UI. I am confused on database end, should i have 2 attribute "region_id" and "region" or I can do with single one.? – Abid Malik Oct 31 '17 at 10:47
  • yes you should create two field in database region_id & state. region_id holds id for that region & state hold state code. – Yogesh Oct 31 '17 at 12:39

Ok I created two attributes region and region_id. In region goes the region name for the countries where we don't have list available and in region_id goes the value of regions select box. I also had to make some changes in Save method to clear values if we edited the field if($data['region_id']){$data['region']=NULL;}. Also had to add attribute in database.

| improve this answer | |

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.