0

I need to display a country list with dropdown in the custom knockout HTML template. Help would be appreciated.

1 Answer 1

1

With reference to this answer.

Magento already provide some inbuilt solution for this.

<?php $countryBlock = $block->getLayout()->createBlock('Magento\Directory\Block\Data');?>

<?= $countryBlock->getCountryHtmlSelect($defValue = null, $name = 'country_id', $id = 'country', $title = 'Country');?>

You can set default $defValue,$name,$id as per as your wise.

6
  • In php we can do that, but how to move this data to HTML file?
    – Ravi Soni
    Commented Jun 16, 2020 at 11:06
  • Thanks it's work.
    – Ravi Soni
    Commented Jun 19, 2020 at 12:34
  • @RaviSoni Happy Coding. Commented Jun 19, 2020 at 13:31
  • Hello @Mayur, have any idea for this question.: magento.stackexchange.com/questions/313382/…
    – Ravi Soni
    Commented Jun 24, 2020 at 7:19
  • @RaviSoni Right now I don't know but if there then I will post soon. Commented Jun 24, 2020 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.