Skip to content

EasyAdmin LocaleField

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).

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, the same which is used by Symfony and many other tech projects. 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, the same which is used by Symfony and many other tech projects. 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 show) 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 show) this field displays the full name of the locale (e.g. Somali (Djibouti), Uyghur (China), Ukrainian, etc.)

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

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