We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add whole countries select list in grav forms.
The text was updated successfully, but these errors were encountered:
This is quite simple really, but does require a 'tiny' bit of code. You can put this code in your current 'theme' or in a custom plugin if you wish.
I'll use the Antimatter theme as an example here: In your themes' php file add this method:
<?php namespace Grav\Theme; use Grav\Common\Theme; class Antimatter extends Theme { public static function countryCodes() { return array ( 'AF' => 'Afghanistan', 'AX' => 'Åland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua & Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AC' => 'Ascension Island', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', ); } }
I've trimmed this down for easy viewing but you can copy/paste the full country list from https://github.com/umpirsky/country-list/blob/master/data/en_US/country.php
This resource has other translations too.
Then all you need to do is reference this static function in your form definition:
country: type: select label: Country data-options@: '\Grav\Theme\Antimatter::countryCodes'
here it is in the admin, but should work the same in the frontend too.
Sorry, something went wrong.
No branches or pull requests
How to add whole countries select list in grav forms.
The text was updated successfully, but these errors were encountered: