Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 5.25 KB

locale.rst

File metadata and controls

115 lines (83 loc) · 5.25 KB

single: Forms; Fields; locale

locale Field Type

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 choice </reference/forms/types/choice> type

from the form </reference/forms/types/form> type

Parent type choice </reference/forms/types/choice>
Class Symfony\\Component\\Form\\Extension\\Core\\Type\\LocaleType

Overridden Options

choices

default: Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleNames()

The choices option defaults to all locales. It uses the default locale to specify the language.

Inherited Options

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 is false and expanded is false, then '' (empty string);
  • Otherwise array() (empty array).