powderblue / sf-continent-country-type
Symfony form-type that displays a list of the countries of the world grouped by continent
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 4
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^8.2.23
- symfony/config: ^5.4|^6.4
- symfony/dependency-injection: ^5.4|^6.4
- symfony/form: ^5.4|^6.4
- symfony/framework-bundle: ^5.4|^6.4
- symfony/http-foundation: ^5.4|^6.4
- symfony/http-kernel: ^5.4|^6.4
- symfony/intl: ^5.4|^6.4
- symfony/options-resolver: ^5.4|^6.4
Requires (Dev)
- phpstan/phpstan: ^1.12.3
- phpunit/phpunit: ^11.3.5
- squizlabs/php_codesniffer: ^3.10.2
This package is auto-updated.
Last update: 2025-05-06 18:48:14 UTC
README
A Symfony bundle that provides a new form-type called "ContinentCountryType". It's like Symfony's CountryType
but allows developers to group countries by continent. The list of countries and continents that are displayed can be easily customised.
Screenshots
(Select2 has been used to render the dropdown lists in the following examples.)
Example of a dropdown with countries grouped by continent:
Example of a 'simple' country dropdown:
Installation
- Run
composer require powderblue/sf-continent-country-type
- Update your project
app/AppKernel.php
file and add the bundle to the$bundles
array:
$bundles = [ // ... new PowderBlue\SfContinentCountryTypeBundle\PowderBlueSfContinentCountryTypeBundle(), ];
Usage
In the buildForm
method of a form-type class, specify ContinentCountryType::class
as the type.
use PowderBlue\SfContinentCountryTypeBundle\Form\Type\ContinentCountryType; // ... $builder // ... ->add('country', ContinentCountryType::class, [ 'label' => 'Country', 'attr' => [ 'placeholder' => 'Country', ], ]) ;
Configuration
Below you can find a reference of all configuration options with their default values:
# config.yml powder_blue_sf_continent_country_type: # The path of the file containing the countries (and continents) that should appear in the dropdown file: "%bundle_root_dir%/Resources/data/continent_country.csv" # Group the countries by continent in the dropdown? group_by_continent: true # The ID of the service used to parse the countries file. It should implement `...\Provider\ContinentCountryProviderInterface`. provider: powder_blue_sf_continent_country_type.provider.continent_country_csv_file