powderblue / sf-continent-country-type
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 4
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.3
- symfony/config: ^4.4|^5.4
- symfony/dependency-injection: ^4.4|^5.4
- symfony/form: ^4.4|^5.4
- symfony/framework-bundle: ^4.4|^5.4
- symfony/http-foundation: ^4.4|^5.4
- symfony/http-kernel: ^4.4|^5.4
- symfony/intl: ^4.4|^5.4
- symfony/options-resolver: ^4.4|^5.4
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.9.1
This package is auto-updated.
Last update: 2024-04-02 15:29:06 UTC
README
Introduction
This is a Symfony 4/5 bundle that provides a new form-type called "ContinentCountryType". This type is 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
Example of a dropdown with countries grouped by continent:
Example of a 'simple' country dropdown:
Note: In the examples, above, Select2 has been used to render the dropdown lists
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(), ];
How to Use
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