Open valtu4a opened 3 years ago
Interesting. In general, our instructions are that if you want to have the ISO code, you should add the field yourself. I am surprised to see that the code appears to attempt to add it for you.
I'll look into it. In the meantime, just add the field yourself if you want the code.
@mrmarkfrench I was trying to set the country dynamically with using the country name from the backend but it was not working as expected. I had to change the country name to iso2 before being able to achieve that. I added $.fn[pluginName].getIso2FromCountry = function(country) { return countries.find(c => c.name === country)?.iso2 || null; }
to get the iso2 before passing it as the defaultCountry. Please let me know your thought if there is already a solution otherwise I make a PR
In the example from the plugin docs I have found additional attribute
data-countrycodeinput="1"
There is also a part of the code which makes a hidden input if it doesn't exist but it doesn't work for me.