LocaleChoiceType is a child of ChoiceType. It is used to display a dropdown selection of available languages/locales configured in PrestaShop. The choices are automatically populated from the shop’s language configuration.
PrestaShopBundle\Form\Admin\TypePrestaShopBundle\Form\Admin\Type\LocaleChoiceType| Option | Type | Default value | Description |
|---|---|---|---|
| placeholder | string | ‘Language’ | Placeholder text shown before selection. Translated via Admin.Global domain. |
| translation_domain | string | ‘Admin.Global’ | Translation domain for the placeholder. |
| choice_translation_domain | boolean | false | Disables translation for choice labels (language names). |
| choices | array | From context | Automatically populated from available shop languages. |
None.
<?php
// path/to/your/CustomType.php
use PrestaShopBundle\Form\Admin\Type\LocaleChoiceType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CustomType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('locale', LocaleChoiceType::class);
}
}
<?php
$builder->add('locale', LocaleChoiceType::class, [
'placeholder' => 'Select a language',
]);
This type is commonly used in translation and international-related forms:
<?php
use PrestaShopBundle\Form\Admin\Type\LocaleChoiceType;
// Export translations form
$builder->add('iso_code', LocaleChoiceType::class, [
'label' => 'Language',
'placeholder' => false, // No empty option
]);
The choices are formatted as key-value pairs where:
Example choices array:
[
'English (English)' => 'en',
'Francais (French)' => 'fr',
'Espanol (Spanish)' => 'es',
]
LocaleChoiceType is used in several PrestaShop forms:
LegacyContext which provides access to the shop’s configured languagesTranslatableType instead