![]() |
Flags Helper - Select Country Dropdown - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Flags Helper - Select Country Dropdown (/showthread.php?tid=25797) |
Flags Helper - Select Country Dropdown - El Forum - 12-25-2009 [eluser]demogar[/eluser] Hello there. I made a basic helper to be used with CodeIgniter when you need a list of countries (useful for user registration, for example). The Country Names are coded in ISO 3166-1 alpha-2. The usage is really simple: Code: # Load the helper You can use and abuse it and you can find the code at GitHub Flags Helper - Select Country Dropdown - El Forum - 12-26-2009 [eluser]Sbioko[/eluser] Thanks! Flags Helper - Select Country Dropdown - El Forum - 12-27-2009 [eluser]Mahyar Ss[/eluser] hi demogar, very useful i need it thnX Flags Helper - Select Country Dropdown - El Forum - 12-28-2009 [eluser]coldKingdom[/eluser] Excellent! Thank you! ![]() Flags Helper - Select Country Dropdown - El Forum - 12-29-2009 [eluser]m4d3 Gun[/eluser] thank's for simple n usefull helper, i already used it...... n work fine. Flags Helper - Select Country Dropdown - El Forum - 12-29-2009 [eluser]demogar[/eluser] Thank you guys. I think I'll convert it in a Library (or add more functions to the helper as well) to get more functionality like get the Country Name if we use the country code and so. I'll keep you updated. Flags Helper - Select Country Dropdown - El Forum - 01-15-2010 [eluser]Watermark Studios[/eluser] I did something similar, but I wanted an array to be passed as a parameter that directs the helper to customize the first few options. Most companies only operate in a few countries, but they want to allow all countries to be available. So I created the below help extension. Just create a file in application/helpers called MY_form_helper.php You can load the helper like you would normally load a helper in a controller Code: $this->load->helper('form'); Code: <?php echo country_dropdown(); ?> Code: <?php echo country_dropdown('country', Below is the function for MY_form_helper.php Code: function country_dropdown($name="country", $top_countries=array()){ Very similar to how yours worked, but with the option to choose the top options which I think is critical for international companies. Also, it is important to find an array of up-to-date ISO 3166 codes. There are 222 codes on the list, I'd hate for you to have to create it like I did (couldn't find an up-to-date version until I saw this post. Flags Helper - Select Country Dropdown - El Forum - 05-16-2013 [eluser]Unknown[/eluser] Thnx demogar and watermark it worked for me. |