single: Forms; Fields; locale
The locale
type is a subset of the ChoiceType
that allows the user to select from a large list of locales (language+country). As an added bonus, the locale names are displayed in the language of the user.
The "value" for each locale is either the two letter ISO 639-1 language code (e.g. fr
), or the language code followed by an underscore (_
), then the ISO 3166-1 alpha-2 country code (e.g. fr_FR
for French/France).
Note
The locale of your user is guessed using Locale::getDefault
Unlike the choice
type, you don't need to specify a choices
or choice_list
option as the field type automatically uses a large list of locales. You can specify either of these options manually, but then you should just use the choice
type directly.
Rendered as | can be various tags (see forms-reference-choice-tags ) |
Overridden Options | |
Inherited options | from the from the
|
Parent type | choice </reference/forms/types/choice> |
Class | Symfony\\Component\\Form\\Extension\\Core\\Type\\LocaleType |
default: Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleNames()
The choices option defaults to all locales. It uses the default locale to specify the language.
These options inherit from the choice </reference/forms/types/choice>
type:
These options inherit from the form </reference/forms/types/form>
type:
The actual default value of this option depends on other field options:
- If
multiple
isfalse
andexpanded
isfalse
, then''
(empty string); - Otherwise
array()
(empty array).