I need to display a country list with dropdown in the custom knockout HTML template. Help would be appreciated.
1 Answer
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.
-
In php we can do that, but how to move this data to HTML file? Commented Jun 16, 2020 at 11:06
-
-
-
Hello @Mayur, have any idea for this question.: magento.stackexchange.com/questions/313382/… 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