Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

CountryChoiceType

CountryChoiceType is a child of ChoiceType. It is used to display countries selection box and by default comes with a list of countries from PrestaShop database.

Type options

Option Type Default value Description
choices array Array of all available countries Choice list that is passed to parent ‘choices’. Array should be formatted in name => value pairs.

Required Javascript components

None.

Code example

<?php
// path/to/your/CustomType.php

use PrestaShopBundle\Form\Admin\Type\CountryChoiceType;
use Symfony\Component\Form\AbstractType;

class CustomType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {        
        $builder->add('country', CountryChoiceType::class);
    }
}

Preview example

CountryChoiceType rendered in form example