Skip to content

EasyAdmin Locale Field

Edit this page

This field is used to represent the name of a locale stored in a property as a valid ICU project locale code (the same which is used by Symfony and many other tech projects).

See also LanguageField and CountryField.

In form pages (edit and new) it looks like this:

Default style of EasyAdmin locale field

Basic Information

  • PHP Class: EasyCorp\Bundle\EasyAdminBundle\Field\LocaleField
  • Doctrine DBAL Type used to store this value: string
  • Symfony Form Type used to render the field: LocaleType
  • Rendered as:

    1
    <select> ... </select>

Options

includeOnly

By default, the locale selector displays all the locales defined by the ICU project. Use this option to only display the given locale codes:

1
yield LocaleField::new('...')->includeOnly(['en', 'fr', 'pl']);

remove

By default, the locale selector displays all the locales defined by the ICU project. Use this option to remove the given locale codes from that list:

1
yield LocaleField::new('...')->remove(['fr', 'pl']);

showCode

By default, in read-only pages (index and detail) this field displays the full name of the locale (e.g. Somali (Djibouti), Uyghur (China), Ukrainian, etc.).

Use this option if you want to display the locale code (e.g. so_DJ, ug_CN, uk, etc.) instead of or in addition to the locale name:

1
yield LocaleField::new('...')->showCode();

showName

By default, in read-only pages (index and detail) this field displays the full name of the locale (e.g. Somali (Djibouti), Uyghur (China), Ukrainian, etc.).

Use this option to hide the locale name. Combine it with showCode() to display the locale code instead; otherwise the field displays nothing:

1
yield LocaleField::new('...')->showName(false);
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version